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 Nov 10 at 12:06
asked Nov 10 at 11:40
Sater
35
35
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
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.
I'm able now to plot my data
– Sater
Nov 12 at 7:58
@Sater that’s great! If this helped for you, can you accept this as an answer
– J.Aluko
Nov 12 at 8:02
if i have one value as <cMeasureItem IsTopCamera="true" dMeasuredThicknesses0="1984.2276044015287" how to get thickness in plot?
– Sater
Nov 12 at 8:07
I'm using his function Thickness = cMeasureItem.get("dMeasuredThicknesses0") I'm getting only the first value not all the file values!! can you help
– Sater
Nov 12 at 8:18
@Sater Sure! Check out this post I replied to the other day, and hopefully that will point you in the right direction. If it helps please up vote it.
– J.Aluko
Nov 12 at 18:28
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
accepted
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.
I'm able now to plot my data
– Sater
Nov 12 at 7:58
@Sater that’s great! If this helped for you, can you accept this as an answer
– J.Aluko
Nov 12 at 8:02
if i have one value as <cMeasureItem IsTopCamera="true" dMeasuredThicknesses0="1984.2276044015287" how to get thickness in plot?
– Sater
Nov 12 at 8:07
I'm using his function Thickness = cMeasureItem.get("dMeasuredThicknesses0") I'm getting only the first value not all the file values!! can you help
– Sater
Nov 12 at 8:18
@Sater Sure! Check out this post I replied to the other day, and hopefully that will point you in the right direction. If it helps please up vote it.
– J.Aluko
Nov 12 at 18:28
add a comment |
up vote
0
down vote
accepted
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.
I'm able now to plot my data
– Sater
Nov 12 at 7:58
@Sater that’s great! If this helped for you, can you accept this as an answer
– J.Aluko
Nov 12 at 8:02
if i have one value as <cMeasureItem IsTopCamera="true" dMeasuredThicknesses0="1984.2276044015287" how to get thickness in plot?
– Sater
Nov 12 at 8:07
I'm using his function Thickness = cMeasureItem.get("dMeasuredThicknesses0") I'm getting only the first value not all the file values!! can you help
– Sater
Nov 12 at 8:18
@Sater Sure! Check out this post I replied to the other day, and hopefully that will point you in the right direction. If it helps please up vote it.
– J.Aluko
Nov 12 at 18:28
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
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 Nov 11 at 13:08
J.Aluko
163
163
I'm able now to plot my data
– Sater
Nov 12 at 7:58
@Sater that’s great! If this helped for you, can you accept this as an answer
– J.Aluko
Nov 12 at 8:02
if i have one value as <cMeasureItem IsTopCamera="true" dMeasuredThicknesses0="1984.2276044015287" how to get thickness in plot?
– Sater
Nov 12 at 8:07
I'm using his function Thickness = cMeasureItem.get("dMeasuredThicknesses0") I'm getting only the first value not all the file values!! can you help
– Sater
Nov 12 at 8:18
@Sater Sure! Check out this post I replied to the other day, and hopefully that will point you in the right direction. If it helps please up vote it.
– J.Aluko
Nov 12 at 18:28
add a comment |
I'm able now to plot my data
– Sater
Nov 12 at 7:58
@Sater that’s great! If this helped for you, can you accept this as an answer
– J.Aluko
Nov 12 at 8:02
if i have one value as <cMeasureItem IsTopCamera="true" dMeasuredThicknesses0="1984.2276044015287" how to get thickness in plot?
– Sater
Nov 12 at 8:07
I'm using his function Thickness = cMeasureItem.get("dMeasuredThicknesses0") I'm getting only the first value not all the file values!! can you help
– Sater
Nov 12 at 8:18
@Sater Sure! Check out this post I replied to the other day, and hopefully that will point you in the right direction. If it helps please up vote it.
– J.Aluko
Nov 12 at 18:28
I'm able now to plot my data
– Sater
Nov 12 at 7:58
I'm able now to plot my data
– Sater
Nov 12 at 7:58
@Sater that’s great! If this helped for you, can you accept this as an answer
– J.Aluko
Nov 12 at 8:02
@Sater that’s great! If this helped for you, can you accept this as an answer
– J.Aluko
Nov 12 at 8:02
if i have one value as <cMeasureItem IsTopCamera="true" dMeasuredThicknesses0="1984.2276044015287" how to get thickness in plot?
– Sater
Nov 12 at 8:07
if i have one value as <cMeasureItem IsTopCamera="true" dMeasuredThicknesses0="1984.2276044015287" how to get thickness in plot?
– Sater
Nov 12 at 8:07
I'm using his function Thickness = cMeasureItem.get("dMeasuredThicknesses0") I'm getting only the first value not all the file values!! can you help
– Sater
Nov 12 at 8:18
I'm using his function Thickness = cMeasureItem.get("dMeasuredThicknesses0") I'm getting only the first value not all the file values!! can you help
– Sater
Nov 12 at 8:18
@Sater Sure! Check out this post I replied to the other day, and hopefully that will point you in the right direction. If it helps please up vote it.
– J.Aluko
Nov 12 at 18:28
@Sater Sure! Check out this post I replied to the other day, and hopefully that will point you in the right direction. If it helps please up vote it.
– J.Aluko
Nov 12 at 18:28
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown