Hi, I am trying to learn and use XML with perl but because of difficulty that I am having with the perldoc XML::Twig and also the website of twig(despite all the tutorials, I decide to seek for help here. honestly, I just don't think I am getting it.

Anyway, I have fairly complicated XML file I want to parse out so that I can do some report on it but I am just not sure how to use XML::Twig nor if XML::Twig is even the right module to use.

I have been
1)trying to read the doc but honestly, it's little bit over my head...
2)trying to follow the tutorials on the website but it's not giving me what I want..(i am sure I am just not getting it .. same for 1) as well but
3)also did super seach on perlmonks w/ following key words ---> xml twig and read pretty much read all posts)

I have wrote a example xml file below and my question is, if I wanted to make a array of id so that my @array will contain qw/ msn movies espn/ how would I go about doing it?

I was thinking somehow using first_child method?
Would appreciate the pointer/advise.
thank you
-------- code that I was just looking at------------- #!/usr/bin/perl use warnings; use strict; use XML::Twig; my $twig = XML::Twig->new(twig_roots => { one => 1}); $twig->parsefile(shift); $twig->print; --- example file ------- <config> <one id="msn" type="shopping"> <traffic> <daily value="on" /> <weekly value="off" /> <monthly value="off" /> </traffic> </one> <one id="movies" type="entertainment"> <traffic> <daily value="on" /> <weekly value="off /> <monthly value="on" /> </traffic> </one> <one id="espn" type="sports"> <traffic> <daily value="on" /> <weekly value="on" /> <monthly value="on /> <hyper value="true /> </traffic> </one> </config>

In reply to 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.