> -Original Message-
> From: Stefan Behnel [mailto:stefan...@behnel.de]
> Sent: Sunday, April 25, 2010 6:42 PM
> To: python-list@python.org
> Subject: Re: Need help with basic DOM XML tree traversing
>
> Barak, Ron, 25.04.2010 17:06:
> > This is my first try at XML with Python, and though I tried
> to read on the web, I'm unable to traverse a DOM tree, as my
> top element seems to be DOCUMENT_NODE and I cannot find a way
> to get to the nodes below it.
>
> You might find the xml.etree.ElementTree package a lot easier
> to work with.
>
>
> > $ python -u xml_parse.py
> > node:
> > dom2.nodeType: 9
> > dom2.nodeName: #document
> > node is DOCUMENT_NODE: > 0x00DE25A8> node:
> > dom2.nodeType: 9
> > dom2.nodeName: #document
> > node is DOCUMENT_NODE:
> > ('dom2._get_childNodes():', [ instance at
> > 0x00DE25A8>,]) Traceback
> (most recent call last):
> >File "xml_parse.py", line 26, in
> >
> >
> print("child_nodes._get_childNodes():",child_nodes._get_childNodes())
> > AttributeError: 'NodeList' object has no attribute '_get_childNodes'
>
> "childNodes" is a property, use it like
>
> print("child_nodes.childNodes:", child_nodes.childNodes)
>
> By convention, the underscore at the beginning of "_get_childNodes"
> indicates that it is not considered a public method.
>
> Stefan
>
>
>
Hi Stefan,
Thanks for the excellent pointer to xml.etree.ElementTree: it sure makes life
easier :-)
Bye,
Ron.
--
http://mail.python.org/mailman/listinfo/python-list