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>

In reply to Re^6: trying to understand xml::twig and also trying to learn how to extract attribute by convenientstore
in thread trying to understand xml::twig and also trying to learn how to extract attribute by convenientstore

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.