[XML-SIG] best way to parse a simple xml string?

Michael Gilbert michael.s.gilbert at gmail.com
Fri Dec 23 21:22:53 CET 2005


Hello all,

I appologize for positing such a trivial question, but I am having trouble
decrypting the python XML documentation.

I am parsing a relatively simple strings, each of which consist of a single
xml tag.  For example:

<user first="jean" last="valjean" dob="17290101" children="1"
hobby="stealing bread" />

What is the best way to determine only the user's hobby?  pulldom, sax,
something else?  is there guidance on using xml tools for single tags?  This
is what I have so far

  from xml.dom.pulldom import *
  a = parseString('<user first="jean" last="valjean" dob="17290101"
children="1" hobby="stealing bread" />')

I've tried getEvent() and expandNode(), but am not getting any closer to
accessing the content in the string.  What are your suggestions on the best
way to retrieve the hobby?  Thank you very much any help.

Hope you all have a happy holiday,
Mike Gilbert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/xml-sig/attachments/20051223/053a1c68/attachment.html


More information about the XML-SIG mailing list