Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: retrieving attribute text with xml::twig

by mirod (Canon)
on Jul 11, 2003 at 00:47 UTC ( #273204=note: print w/ replies, xml ) Need Help??


in reply to retrieving attribute text with xml::twig

The attributes are accessed using $_->atts , the values would then be values %{$_->atts}.

Just for the fun here is a compact way to do this:

#!/usr/bin/perl -w use strict; use XML::Twig; XML::Twig->new( start_tag_handlers => { _all_ => sub { print join( ' - ' => values %{$_->a +tts}), "\n"; } } ) ->parse( \*DATA); __DATA__ <doc> <elt att="first attribute">text</elt> <elt att="second attribute" att2="foo">text</elt> <elt att="bar">text</elt> </doc>


Comment on Re: retrieving attribute text with xml::twig
Download Code
Re: Re: retrieving attribute text with xml::twig
by Anonymous Monk on Jul 13, 2003 at 02:02 UTC
    thank you Monk Mirod, Ivo

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://273204]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-12-19 07:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (73 votes), past polls