Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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


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');

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997469]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2018-04-22 11:33 GMT
Find Nodes?
    Voting Booth?