DunLidjun has asked for the wisdom of the Perl Monks concerning the following question:
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:
I have a gotoButton on two levels and I've been able to get the name for each button using the following code:<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>
#!/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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl LibXML Help.
by choroba (Cardinal) on Jan 29, 2014 at 15:59 UTC | |
by DunLidjun (Acolyte) on Jan 29, 2014 at 16:17 UTC | |
|
Re: Perl LibXML Help.
by simmisam (Novice) on Jan 29, 2014 at 21:20 UTC | |
by DunLidjun (Acolyte) on Jan 29, 2014 at 21:48 UTC | |
|
Re: Perl LibXML Help.
by Discipulus (Canon) on Jan 30, 2014 at 10:41 UTC |