Posted on 2005-07-08 14:33:38-07 by mjash
nodeset vs childnodes
I've noticed something unexpected when using the
XML::XPath::Node::Element::getChildNodes()
rather than
XML::XPath::find($path,$context)

Given a node in a nodeset:
foreach $node ($nodeset->get_nodelist());
If I subsequently use
find($subPath, $node)
again to get a nodelist for each node, I get for the nodeset size say,
size() == 2
.However, if I use
$node->getChildNodes()
I get a list of child nodes of size five!

Looking at the the list more closely I see that there are the same two (element)nodes found with find() but there are also three additional (text) nodes. (text,element1,text,element2,text). I note that the text nodes contain only the LF of the actual XML file found in-between the element nodes.
Why is there this difference when using getChildNodes()?
-mjash
Direct Responses: 738 | Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.