I have some XML that I've been parsing using XML::LibXML. I've been trying to get some data from the parsing an have been unable to sucessfully get the information.

A sample of the XML is below:

<gfx> <group name="Group1" visible="true" wallpaper="false" isReferenceOb +ject="false"> <gotoButton name="GotoDisplayButton3" display="19 UNIT STATUS"> <caption fontFamily="Arial" fontSize="9" caption="MAIN MEN +U" /> <imageSettings imageName="" alignment="middleCenter"/> </gotoButton> </group> <gotoButton name="GotoDisplayButton12" display="36 AIR_OIL SYSTEM SE +TUP_2"> <caption fontFamily="Arial" fontSize="9" caption="TO CRXW616&# +xA;AIR/OIL" /> <imageSettings imageName="" alignment="middleCenter"/> </gotoButton> </gfx>
I have a gotoButton on two levels and I've been able to get the name for each button using the following code:
#!/usr/bin/perl # use strict; use warnings; use threads; use XML::LibXML; my $parser = XML::LibXML->new(); my $doc = $parser->parse_file("file.xml"); foreach my $title ($doc->findnodes('//gotoButton')) { my $button = $title->getAttribute('name'); my $display = $title->getAttribute('display'); print "$button\t$display\n"; }

What I'm trying to do is get the above information as well as the child's caption caption from each of the groups.

Ideally, I'd like to get from the data above:

GotoDisplayButton3 19 UNIT STATUS MAIN MENU

GotoDisplayButton12 36 AIR_OIL SYSTEM SETUP_2 TO CRXW616 AIR/OIL

Are there any hints that you could give using LibXML? I've gone through the documentation and nothing is jumping out at me.

Thanks

Shawn Way


In reply to Perl LibXML Help. by DunLidjun

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.