[XML-SIG] DOM seems incomplete

Markus Jostock markus.jostock at softwareag.com
Tue Aug 10 11:59:16 CEST 2004


Hi

I am parsing a string into a DOM. That works without problems. But when 
I want to access childen of the first element, there seem to be none. 
But pretty printing shows them.

Maybe you have an idea what might be going wrong?

Thanks in advance for some clues.

Kind regards
    Markus


The string I parse:
string = '<MYXML><DOCUMENT><DOCAT INFO="" 
STATUS="PRV"><DOCAT.HEAD.LK><LINK DOC="!NEW!" 
/></DOCAT.HEAD.LK><RESAT.LK><LINK DOC="!NEW!" 
/></RESAT.LK></DOCAT></DOCUMENT></MYXML>'

Parsing works without errors:
    from xml.dom.ext.reader import Sax2
    reader = Sax2.Reader()
    doc = reader.fromString(string)

When I pretty print it, it looks ok:
    from xml.dom.ext import PrettyPrint
    PrettyPrint(doc)
prints:
<?xml version='1.0' encoding='UTF-8'?>
<MYXML>
    <DOCUMENT>
        <DOCAT INFO='' STATUS='PRV'>
            <DOCAT.HEAD.LK>
                <LINK DOC='!NEW!'/>
            </DOCAT.HEAD.LK>
            <RESAT.LK>
                <LINK DOC='!NEW!'/>
            </RESAT.LK>
        </DOCAT>
    </DOCUMENT>
</MYXML>

Accessing doc.firstChild is ok:
print doc.firstChild.nodeName  prints MYXML

But if a want to access further children of <MYXML>, there are none:
print doc.firstChild.nodeList prints <NodeList at c43968: []> or
print doc.firstChild.firstChild prints None

Where are my children gone?



More information about the XML-SIG mailing list