Problem with pyXML DOM
Maniac
Maniac at SoftwareManiacs.Org
Wed May 4 08:01:48 EDT 2005
Florian Lindner wrote:
>But I don't really understand the logic:
>
>given I have the node A
>
><filename>path</filename>
>
>A.firstChild.nodeValue == path
>
>How would the second child of A look like? (ok, None in this case)
>
Yes. It's actually required by DOM standard: NodeList (which is returned
from getElementsByTagName) should return 'null' (None in Python) on
unknown index:
http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-844377136
> How would
>a XML fragment look like that has a second child?
>
>
Like this for example:
<filename><child/><child/></filename>
or like this:
<filename>I'm a text child node <ElementChildNode/></filename>
>What would be the nodeValue of A?
>
>
It's not related to children. There are several types of nodes:
documents, elements, text, comments, processing instructions (things in
<??>)... Their nodeValue depends on their nature.
http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-844377136
>for me a child of a node is something like
>
><filename>
> <child1 />
> <child2 />
></filename>
>
>
Almost :-). Here filename has actually 5 nodes:
1. text node '\n '
2. element node 'child'
3. text node '\n '
4. element node 'child'
5. text node '\n'
In other words: in DOM whitespace counts.
More information about the Python-list
mailing list