I was hoping this would work but still no go..
use strict; use warnings; use XML::Twig; my $xml = <<XML; <foo> <yahoo V="bay"> <bay_id> <value>1</value> <fact>yes</fact> </bay_id> <bay_seen> <value>10</value> <fact>no</fact> </bay_seen> <bay_overall value="disabled"/> <bayking_list> <bayking id="kingjames" country="usa" active="true"> <bayking type="dictator"/> <bay_usage value="none"/> <bayking_origin> <bayking_origin_name value="ohio_usa" emmigrat +e="no"> <economy_status_previous value="very po +or" /> </bayking_origin_name> </bayking_origin> </bayking> </bayking_list> <bayqueen_list> <bayqueen id="queenliz" country="france" active="true"> <bayqueen type="dictator"/> <bay_usage value="none"/> <bayqueen_origin> <bayqueen_origin_name value="ohio_usa" emmigra +te="no"/> </bayqueen_origin> </bayqueen> </bayqueen_list> </yahoo> <yahoo V="baz"> <bay_id> <value>1000</value> <fact>yes</fact> </bay_id> <bay_seen> <value>50</value> <fact>no</fact> </bay_seen> <bay_overall value="disabled"/> <bayking_list> <bayking id="kingtony" country="Russia" active="true"> <bayking type="dictator"/> <bay_usage value="none"/> <bayking_origin> <bayking_origin_name value="ohio_usa" emmigrat +e="no"> <economy_status_previous value="very po +or" /> </bayking_origin_name> </bayking_origin> </bayking> </bayking_list> <bayqueen_list> <bayqueen id="queensarah" country="japan" active="true"> <bayqueen type="dictator"/> <bay_usage value="none"/> <bayqueen_origin> <bayqueen_origin_name value="ca_usa" emmigrate +="no"/> <economy_status_previous value="very po +or" /> <previous marriage="no"/> </bayqueen_origin> </bayqueen> </bayqueen_list> </yahoo> </foo> XML my $sabal = new XML::Twig( twig_roots => { 'foo/yahoo' => #'bayking[@id="kingtony"]' => sub { my ($yabal, $element ) = @_; if ( $yabal->bayking_list->bayking->att(' +id') eq 'kingtony' ) { $element->print; } } } ); $sabal->parse($xml);

In reply to Re^8: xml::twig gathering all element and att and its value question by convenientstore
in thread xml::twig gathering all element and att and its value question 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.