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
Posted on 2005-07-14 18:16:47-07 by mjash in response to 712
Re: nodeset vs childnodes
Never mind...
the $subPath in find() contains the specific name of the childnodes that I'm attempting to retrieve wereas getChildNodes() gives them all to me. There is also the subtle details of how WHITE SPACE is treated. -mjash
Direct Responses: 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.