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

Re^5: trying to understand xml::twig and also trying to learn how to extract attribute

by convenientstore (Pilgrim)
on Nov 05, 2008 at 22:31 UTC ( [id://721843]=note: print w/replies, xml ) Need Help??


in reply to Re^4: trying to understand xml::twig and also trying to learn how to extract attribute
in thread trying to understand xml::twig and also trying to learn how to extract attribute

this gives me much better idea and also give me more idea for further code.. will get back to you soon.. thank you.
  • Comment on Re^5: trying to understand xml::twig and also trying to learn how to extract attribute

Replies are listed 'Best First'.
Re^6: trying to understand xml::twig and also trying to learn how to extract attribute
by convenientstore (Pilgrim) on Nov 06, 2008 at 15:03 UTC
    can I just specify first_child of any element within the root?
    first_child ($optional_condition)

    Return the first child of the element, or the first child matching the $optional_condition

    for e.g., given below xml, in order to get to <getthis value="found" />, do I always have to go
    if ($one->first_child('traffic')->first_child('something')->fir +st_child('somethingelse')->first_child('getthis')->att('value') eq 'f +ound') { push @ids, $one->att('id'); push @ids, $one->true('yes'); }
    OR can I just pick the element like
    if ($one->first_child('getthis')->att('value') eq 'found') { push @ids, $one->att('id'); push @ids, $one->true('yes'); }
    Another words, is first_child definition the child of the root?(in this case , 'one' and then 'traffic' and then so on.. and therefore need to go down the chain in steps or can I say my parent is one and then first child is 'getthis' ?
    <one id="msn" type="shopping"> <traffic> <daily value="on" /> <weekly value="off" /> <something> <somethingelse> <getthis value="found" true="yes" /> <somethingelse> </something> <monthly value="off" /> </traffic> </one>

Log In?
Username:
Password:

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

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

    No recent polls found