Parse XML file



examples/applications/simple.xml
<people>
  <person id="1">
    <fname>Josef</fname>
    <lname>Kiss</lname>
    <idnum>4342324234</idnum>
    <children>
      <child>
        <id>3</id>
      </child>
    </children>
  </person>
  <person id="2">
    <fname>Peter</fname>
    <lname>Kiss</lname>
    <idnum>8768996</idnum>
  </person>
  <person id="3">
    <fname>Zoltan</fname>
    <lname>Kiss</lname>
    <idnum>09808760</idnum>
  </person>
</people>

examples/applications/xml_simple.pl
#!/usr/bin/env perl
use strict;
use warnings;

use XML::Simple qw(XMLin);

my $xml = XMLin("examples/simple.xml", ForceArray => 1);
#use Data::Dumper qw(Dumper);
#print Dumper $xml;
#exit;

print join "-", keys %{$xml->{person}};
print "\n";

foreach my $id (keys %{$xml->{person}}) {
    printf "%-10s %-10s %-10s\n",
        $xml->{person}{$id}{fname}[0],
        $xml->{person}{$id}{lname}[0],
        $xml->{person}{$id}{idnum}[0];
}