Extract and plot XML data using python
up vote
-1
down vote
favorite
I'm trying to analyze my XML file, I would like to get data X Y Z for advanced analysis later and then plot all values.
Here the XML files looks like:
<UserPosition>
<X>-12.2934008394709</X>
<Y>52.488259963403273</Y>
<Z>-0.92276278637695341</Z>
</UserPosition>
this is my code :
from lxml import etree
import matplotlib.pyplot as plt
import numpy as np
# Read xml files
PostX =
PostY=
Thikness =
tree = etree.parse("XMLFILE.xml")
for UserPosition in
tree.xpath("/cResult/measure/lMeasuredItem/cMeasureItem/UserPosition/X"):
PostX.append(UserPosition.text)
print PostX
I'm getting this ! :
['-12.2934008394709', '-9.1133008238197366', '-5.9329608027622784', '-2.7523007917339029',
Any help to get a proper values for analysis.
python xml
add a comment |
up vote
-1
down vote
favorite
I'm trying to analyze my XML file, I would like to get data X Y Z for advanced analysis later and then plot all values.
Here the XML files looks like:
<UserPosition>
<X>-12.2934008394709</X>
<Y>52.488259963403273</Y>
<Z>-0.92276278637695341</Z>
</UserPosition>
this is my code :
from lxml import etree
import matplotlib.pyplot as plt
import numpy as np
# Read xml files
PostX =
PostY=
Thikness =
tree = etree.parse("XMLFILE.xml")
for UserPosition in
tree.xpath("/cResult/measure/lMeasuredItem/cMeasureItem/UserPosition/X"):
PostX.append(UserPosition.text)
print PostX
I'm getting this ! :
['-12.2934008394709', '-9.1133008238197366', '-5.9329608027622784', '-2.7523007917339029',
Any help to get a proper values for analysis.
python xml
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm trying to analyze my XML file, I would like to get data X Y Z for advanced analysis later and then plot all values.
Here the XML files looks like:
<UserPosition>
<X>-12.2934008394709</X>
<Y>52.488259963403273</Y>
<Z>-0.92276278637695341</Z>
</UserPosition>
this is my code :
from lxml import etree
import matplotlib.pyplot as plt
import numpy as np
# Read xml files
PostX =
PostY=
Thikness =
tree = etree.parse("XMLFILE.xml")
for UserPosition in
tree.xpath("/cResult/measure/lMeasuredItem/cMeasureItem/UserPosition/X"):
PostX.append(UserPosition.text)
print PostX
I'm getting this ! :
['-12.2934008394709', '-9.1133008238197366', '-5.9329608027622784', '-2.7523007917339029',
Any help to get a proper values for analysis.
python xml
I'm trying to analyze my XML file, I would like to get data X Y Z for advanced analysis later and then plot all values.
Here the XML files looks like:
<UserPosition>
<X>-12.2934008394709</X>
<Y>52.488259963403273</Y>
<Z>-0.92276278637695341</Z>
</UserPosition>
this is my code :
from lxml import etree
import matplotlib.pyplot as plt
import numpy as np
# Read xml files
PostX =
PostY=
Thikness =
tree = etree.parse("XMLFILE.xml")
for UserPosition in
tree.xpath("/cResult/measure/lMeasuredItem/cMeasureItem/UserPosition/X"):
PostX.append(UserPosition.text)
print PostX
I'm getting this ! :
['-12.2934008394709', '-9.1133008238197366', '-5.9329608027622784', '-2.7523007917339029',
Any help to get a proper values for analysis.
python xml
python xml
edited yesterday
asked yesterday
Sater
14
14
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Is there any reason you cant change
PostX.append(UserPosition.text)
to
PostX.append(float(UserPosition.text))
Otherwise, it would be helpful to see how it is all your x, y and z values (or certainly more of them) are structured in this .xml file.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Is there any reason you cant change
PostX.append(UserPosition.text)
to
PostX.append(float(UserPosition.text))
Otherwise, it would be helpful to see how it is all your x, y and z values (or certainly more of them) are structured in this .xml file.
add a comment |
up vote
0
down vote
Is there any reason you cant change
PostX.append(UserPosition.text)
to
PostX.append(float(UserPosition.text))
Otherwise, it would be helpful to see how it is all your x, y and z values (or certainly more of them) are structured in this .xml file.
add a comment |
up vote
0
down vote
up vote
0
down vote
Is there any reason you cant change
PostX.append(UserPosition.text)
to
PostX.append(float(UserPosition.text))
Otherwise, it would be helpful to see how it is all your x, y and z values (or certainly more of them) are structured in this .xml file.
Is there any reason you cant change
PostX.append(UserPosition.text)
to
PostX.append(float(UserPosition.text))
Otherwise, it would be helpful to see how it is all your x, y and z values (or certainly more of them) are structured in this .xml file.
answered 17 hours ago
J.Aluko
12
12
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238558%2fextract-and-plot-xml-data-using-python%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password