in reply to Perl LibXML Help.

You can use perl's XML::Simple module, it's easy to use too

#!/usr/bin/perl use strict; use warnings; use XML::Simple; use Data::Dumper; my $xml = new XML::Simple; my $data = $xml->XMLin("test.xml"); print Dumper $data; print "$data->{'group'}{'gotoButton'}{'name'} - "; print "$data->{'group'}{'gotoButton'}{'display'}\n"; print "$data->{'gotoButton'}{'name'} - "; print "$data->{'gotoButton'}{'display'}\n"; Output: $VAR1 = { 'gotoButton' => { 'imageSettings' => { 'imageName' => '', 'alignment' => 'middleCen +ter' }, 'caption' => { 'fontFamily' => 'Arial', 'caption' => 'TO CRXW616 AIR/OIL', 'fontSize' => '9' }, 'name' => 'GotoDisplayButton12', 'display' => '36 AIR_OIL SYSTEM SETUP_2' }, 'group' => { 'gotoButton' => { 'imageSettings' => { 'imageName' => + '', 'alignment' => + 'middleCenter' }, 'caption' => { 'fontFamily' => 'Ari +al', 'caption' => 'MAIN M +ENU', 'fontSize' => '9' }, 'name' => 'GotoDisplayButton3', 'display' => '19 UNIT STATUS' }, 'visible' => 'true', 'wallpaper' => 'false', 'name' => 'Group1', 'isReferenceObject' => 'false' } }; GotoDisplayButton3 - 19 UNIT STATUS GotoDisplayButton12 - 36 AIR_OIL SYSTEM SETUP_2

Using dumper, you will get the data inside the xml file in perl datastructure i.e, hash of hashes or arrays from which data can be pulled out in similar manner as I have mentioned in code.

Replies are listed 'Best First'.
Re^2: Perl LibXML Help.
by DunLidjun (Acolyte) on Jan 29, 2014 at 21:48 UTC

    I actually started out using this, but I was having issues with multiple levels.

    We could access both the group/gotoButton and gotoButton tags easily enough; however, I would have to code in each level individually. This is ok if the XML can only have two levels, but it is possible to further nest these variables, making it hard to predict the final depth I would need to code this.

    Thanks though!

    Shawn Way