Re: how can I get the attribute names?

Michael Ludwig <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
xu zhou schrieb:
>  Suppose I have "<link rel='self','href'='www.newsmth.net'>"

That's a syntax error - no comma allowed there, not well-formed.

> and I do not even know the attribute names "ref/href", how can I get
> all the attribute information using XML::LibXML?

use strict;
use warnings;
use XML::LibXML;
my $parser = XML::LibXML->new;
my $doc = $parser->parse_string( '<Urmel bla="3" blub="4"/>');
print $_->name, "\t", $_->value, "\n"
         for $doc->documentElement->attributes;

See:

   perldoc XML::LibXML::Node
   perldoc XML::LibXML::Attr

Michael Ludwig
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.