I need to store the elements separated by comma in xml tags
For example, these x and y coordinates:
<points>
<point>558.000000,790.000000</point>
<point>530.000000,829.000000</point>
<point>567.000000,855.000000</point>
<point>595.000000,815.000000</point>
<point>558.000000,790.000000</point>
</points>
I tried something like this
x1, y1 = ((item.getElementsByTagName('points')[0]).getElementsByTagName('point')[0]).firstChild.data
But got the following error
ValueError: too many values to unpack (expected 2)
Any help in this will be appreciated.
I have recently work on accessing the XML tags and I prefer
xml.dom.minidom
library of python for this use.The code for your above-mentioned XML tags in the question is:
The output for above-mentioned code is split with x and y coordinates and stored in an array as you requested in the question. The output can be seen below:
Hope this help, please let me know if this is what you want.