ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved