Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Parsing XML with XML::Simple

by GrandFather (Cardinal)
on Dec 18, 2006 at 00:54 UTC ( #590367=note: print w/ replies, xml ) Need Help??


in reply to Parsing XML with XML::Simple

XML::Twig seems to do what you want if you Simplify things a little:

use strict; use warnings; use XML::Twig; use Data::Dump::Streamer; my $twig = XML::Twig->new (); $twig->parse (*DATA); my $hash = $twig->simplify (); Dump ($hash); __DATA__ <XML> <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> </XML>

Prints:

$HASH1 = { ARTICLE => "\nfoo bar baz\n", AUTHOR => 'Bar', content => "\n\$Id: File_Find.pl,v 1.1 2006-12-17 19:25:03 e +ric Exp \$\n2006-12-10BlahFo". "oBar\n...\n\nfoo bar baz\n", CVS => "\n\$Id: File_Find.pl,v 1.1 2006-12-17 19:25:03 e +ric Exp \$\n", DATE => '2006-12-10', INTRODUCTION => 'Blah', TITLE => 'Foo' };

DWIM is Perl's answer to Gödel


Comment on Re: Parsing XML with XML::Simple
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://590367]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2014-11-23 11:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (131 votes), past polls