Accessing name part of attributes using XML::LIbXML::Attr class
Ira T Taylor <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <OFD7E52EFC.82C8A600-ON862575D1.004A6133-862575D1.004B1657@mck.us.ray.com> |
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
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs