RE: Question about getNodeName
by Mark - BLS CTR Thomas other posts by this author
Jun 13 2006 2:30PM messages near this date
view in the new Beta List Site
Question about getNodeName
|
Re: Question about getNodeName
& XSLT Mesdaq, Ali wrote:
> When using DOM and getNodeName I get the name and
> "#text" returned. Why is #text returned and how
> can I have only the name returned?
Because text nodes are nodes. getChildNodes() will return text nodes,
which don't have names.
> my $root = $doc->getDocumentElement();
> my @installinfo = $root->getChildNodes();
> foreach my $run (@installinfo)
> {
> print $run->getNodeName(), "\n";
> }
Assuming you're using an Xpath-aware parser, you can do:
print map { $_-> nodeName . "\n" } $doc->findnodes('/*/*');
Because * doesn't match text nodes in Xpath.
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Ali Mesdaq
Mark - BLS CTR Thomas
Petr Pajas
Bjoern Hoehrmann
|