On 07/05/14 14:13, jitendra gupta wrote:
I thought to do via read a line by line with normal file handling. but
there a problem with that. So i want to handle python XML . Could you
please suggest on this.
Python comes with several XML parsers. The simplest to use are probably
sax and ElementTree (aka etree). The documenation gives examples of
both. sax is easiest and fastest for simple XML in big files while etree
is probably better for more complex XML structures.
Your XML looks fairly simple
<?xml version="1.0"?>
<data>
<country name="Liechtenstein">
<rank updated="yes">2</rank>
<year>2008</year>
<gdppc>141100</gdppc>
<neighbor name="Austria" direction="E"/>
<neighbor name="Switzerland" direction="W"/>
</country>
</data>
Either parser should be fine, see which one suits your
personal style best.
For more specific help we need more specific information.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor