This seems to work for me. You mentioned wrapping a root element around it, but did you include the <?xml ...?> bit? Even when I remove that, though, it still works. Does it fail with your sample file?
#!/usr/bin/perl use XML::Simple; my $xml = do { local $/; <DATA> }; my $hash = XMLin( $xml ); use Data::Dumper; print Dumper( $hash ); __END__ <?xml version="1.0"?> <root> <CVS> $Id: File_Find.pl,v 1.1 2006-12-17 19:25:03 eric Exp $ </CVS> <DATE>2006-12-10</DATE> <INTRODUCTION>Blah</INTRODUCTION> <TITLE>Foo</TITLE> <AUTHOR>Bar</AUTHOR> <ARTICLE> foo bar baz </ARTICLE> </root>
It looks like the hash does what it should:
]$ perl test $VAR1 = { 'INTRODUCTION' => 'Blah', 'CVS' => ' $Id: File_Find.pl,v 1.1 2006-12-17 19:25:03 eric Exp $ ', 'ARTICLE' => ' foo bar baz ', 'TITLE' => 'Foo', 'AUTHOR' => 'Bar', 'DATE' => '2006-12-10' };
Update: If I move the data out to a file and use XMLin( $ARGV[0], NoAttr => 1 ) it still works.
In reply to Re: Parsing XML with XML::Simple
by brian_d_foy
in thread Parsing XML with XML::Simple
by madbombX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |