XML-XPath - nodeset vs childnodes

Posted on Fri Jul 8 17:33:38 2005 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