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
Accessing name part of attributes using XML::LIbXML::Attr class
by Ira T Taylor other posts by this author
Jun 10 2009 6:40AM messages near this date
view in the new Beta List Site
| Re: Accessing name part of attributes using XML::LIbXML::Attr class
& XSLT XML::LibXML::Nodes  has a method:
attributes
 @attributelist = $node-> attributes();
This function returns all attributes and namespace declarations assigned 
to the given node.

Because XML::LibXML does not implement namespace declarations and 
attributes the same way, it is required to test what kind of node is 
handled while accessing the functions result.

If this function is called in array context the attribute nodes are 
returned as an array. In scalar context the function will return a 
XML::LibXML::NamedNodeMap object.

I am using the XML::LibXML::Iterator class.  I can access the value part 
of an attribute using the getValue() method of the Attr class, but I can't 
figure out how to access the value part of the attribute.  It can't find 
any reference to the NamedNodeMap anywheres.

@attributeslist = $curnode-> attributes();
        foreach $value (@attributeslist) {
            $string = $value-> getValue();
            print "name " . $name-> nodeName() . " value $string\n"

Any help would be appreciated,

Ira Taylor
Thread:
Ira T Taylor
Michael Ludwig

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