Firstly, I am confused by your Perl code. I have no experience using XML::Simple (but I have used XML::Parser), but it seems odd that you specify the output file as $conf in your constructor statement, then you use $conf as an input file in your call to XMLin.
Secondly, when I try to read your XML code in using XMLin, I get the following error trace:
Uncaught exception from user code:
not well-formed (invalid token) at line 2, column 10, byte 17 at /usr/
+lib64/perl5/vendor_perl/5.8.0/x86_64-linux-thread-multi/XML/Parser.pm
+ line 185
XML::Parser::parse('XML::Parser=HASH(0x803ab0)','*XML::Simple:
+:XML_FILE') called at /usr/lib/perl5/vendor_perl/5.8.0/XML/Simple.pm
+line 334
XML::Simple::build_tree_xml_parser('XML::Simple=HASH(0x8227a0)
+','foo.xml','foo.xml') called at /usr/lib/perl5/vendor_perl/5.8.0/XML
+/Simple.pm line 277
XML::Simple::build_tree('XML::Simple=HASH(0x8227a0)','foo.xml'
+,'foo.xml') called at /usr/lib/perl5/vendor_perl/5.8.0/XML/Simple.pm
+line 220
XML::Simple::XMLin('XML::Simple=HASH(0x8227a0)','foo.xml') cal
+led at ./655609.pl line 15
Here is my hacked code:
#!/usr/bin/env perl
use warnings;
use strict;
use diagnostics;
use XML::Simple;
my $conf = 'out.xml'; # I made this up
my $xmlfile = new XML::Simple (
Outputfile => $conf,
ForceArray => 1,
RootName=>'exec'
);
#my $xml = $xmlfile->XMLin($conf);
my $xml = $xmlfile->XMLin('foo.xml');
However, if I add double-quotes around the attribute values (001, 002, 003), I can read the XML file in without errors.
Please be more specific about what problem you are having. Are you getting any warning or error messages? If so, please post them here. |