[XML-SIG] Basic Question

Larry Cuba cuba at iotacenter.org
Tue Feb 3 17:25:58 EST 2004


Hi Folks,

I'm new to PyXML and having trouble finding the answer
to a most basic question.

With this slight modification of the sample code in section 6.5
of the Python/XML How To, Walking the Over the Entire Tree:

>walker = xml_dom_object.createTreeWalker(xml_dom_object.documentElement,
>                               NodeFilter.SHOW_ALL, None, 0)
>while 1:
>     print walker.currentNode.nodeName, walker.currentNode.nodeValue
>     next = walker.nextNode()
>     if next is None: break

I was able to get this output (every node name followed by its value):

City None
#text Santa Monica
#text

State None
#text CA
#text

Country None
#text US
#text

The output I want is just the element name
and the *element* value (not node value):

City Santa Monica
State CA
Country US
...

The relevant methods and/or attributes and
how to use them are not well documented,
(not for a beginner, at least).

Can someone explain this to me?

Thanks muchly.

Larry Cuba






More information about the XML-SIG mailing list