[Tutor] Read XML records one by one

Glen Zangirolami glenbot at gmail.com
Mon Mar 8 17:49:40 CET 2010


Another alternative to parsing XML is beautiful soup.

Website:
http://www.crummy.com/software/BeautifulSoup/

Documentation for parsing xml:
http://www.crummy.com/software/BeautifulSoup/documentation.html#Parsing%20XML

sample code:
from BeautifulSoup import BeautifulStoneSoup
xml = "<doc><tag1>Contents 1<tag2>Contents 2<tag1>Contents 3"
soup = BeautifulStoneSoup(xml)
print soup.prettify()
# <doc>
#  <tag1>
#   Contents 1
#   <tag2>
#    Contents 2
#   </tag2>
#  </tag1>
#  <tag1>
#   Contents 3
#  </tag1>
# </doc>



On Mon, Mar 8, 2010 at 3:48 AM, Hichiro <vinh.dhbk at gmail.com> wrote:

>
> Hi all!
> I'm trying to read one by one record in XML file to find out its tag and
> attribute for schema matching. But I haven't done yet. So, could you help
> me?!
> Thanks so much! :)
>
>
>
>
> --
> Best regards,
> Vinh NV
> CNPM K50 DHBKHN
> Y!    : Vinh.dhbk
> Sky : Vinh.dhbk
> 84 976 314 988
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100308/71b4a31b/attachment-0001.html>


More information about the Tutor mailing list