Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: xml::twig gathering all element and att and its value question

by Jenda (Abbot)
on Nov 12, 2008 at 15:15 UTC ( [id://723180]=note: print w/replies, xml ) Need Help??


in reply to xml::twig gathering all element and att and its value question

use XML::Rules; XML::Rules->new( stripspaces => 7, rules => { lease => sub {return 'lease' => $_[1]->{true}}, extra_device => sub {return 'extra_device' => $_[1]->{value}}, computer => sub { if ($_[1]->{extra_device}) { print "computer id: $_[1]->{id} type: $_[1]->{type} os +: $_[1]->{os} lease:$_[1]->{lease} extra_device=$_[1]->{extra_device} +\n"; } else { print "computer id: $_[1]->{id} type: $_[1]->{type} os +: $_[1]->{os} lease:$_[1]->{lease}\n"; } return; } } )->parse(\*DATA); __DATA__ <config> <computer id="one" type="mac" os="XP" > <lease true="yes" /> <extra_device value="scanner"/> </computer> <computer id="two" type="pc" os="NT" > <lease true="no" /> </computer> </config>

Sometimes it's better to reach for a different hammer. Even if you already have a hammer in your hand.

  • Comment on Re: xml::twig gathering all element and att and its value question
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-23 13:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found