Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Struggling with XML

by remiah (Hermit)
on Oct 05, 2012 at 13:05 UTC ( #997469=note: print w/ replies, xml ) Need Help??


in reply to Struggling with XML

Hello.

With XML::Twig, maybe something like this. Twig has nice tutorial.

use strict;use warnings; use XML::Twig; my $t=XML::Twig->new( twig_roots => { '/root/dict[@key="data"]/list/dict' => sub { my ($twig,$elt)=@_; printf "%s = %s\n", $elt->att("key"), $elt->first_child_te +xt; }, }, )->parsefile('your.xml');


Comment on Re: Struggling with XML
Download Code
Re^2: Struggling with XML
by agentorange (Sexton) on Oct 05, 2012 at 13:28 UTC
    Looks like my login timed out whilst posting original. Thanks for responses. As I say I'm very new to Perl, ie. a couple of days, and not sure I fully understand the first response and cannot get XML::Twig to compile.
    Writing Makefile for XML::Twig malformed JSON string, neither array, object, number, string or atom, +at character offset 0 (before "(end of string)") at Makefile.PL line +147
    Therefore ideally a solution with XML::Simple or XML::LibXML would be preferable if possible. I think I'm close with the existing code just maybe not quite understanding something.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-12-27 21:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls