norricorp has asked for the wisdom of the Perl Monks concerning the following question:
It does not work as expected. It is not picking up text nodes so <title>book title</title> shows title which has a text element ("book title") and so has children. But it is not picking up the text nodes. What am I doing wrong? regards, Johnforeach $node ($dom->findnodes('//*')) { if ($node->nodeType() == 3) { print "found a text node\n"; } print "node name is ", $node->nodeName(), "\n"; if ($node->hasChildNodes() == 0) # FALSE { print "No children: node text is ", $node->textContent(), "\n" +; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::LibXML problem
by choroba (Cardinal) on Dec 29, 2011 at 11:03 UTC | |
by norricorp (Initiate) on Dec 29, 2011 at 14:11 UTC | |
by choroba (Cardinal) on Dec 29, 2011 at 14:27 UTC | |
by norricorp (Initiate) on Dec 29, 2011 at 16:11 UTC | |
by choroba (Cardinal) on Dec 29, 2011 at 16:18 UTC | |
| |
|
Re: XML::LibXML problem
by Khen1950fx (Canon) on Dec 29, 2011 at 10:19 UTC | |
|
Re: XML::LibXML problem
by thomas895 (Deacon) on Dec 29, 2011 at 09:58 UTC |