Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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');

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997469]
help
Chatterbox?
[choroba]: I fear so. We have offices in Prague, Brno, Saigon and San Francisco.
[Discipulus]: choroba if let your company to hire Tanktalus and marioroy ... what a big fishing!
[Discipulus]: i choice prague!!
[choroba]: 1200 years is enough :-)
[marioroy]: Lady_Aleena my $ans = qx! find . -name "*.pl" -exec ls -l {} \\; !;
[Tanktalus]: My basic problem right now is that if I were willing to move, I could be back in Toronto with a pay raise. We have a number of reasons for not wanting to do that.
[marioroy]: I had to backslash the backslash inside qx.
[Tanktalus]: marioroy++ # nice catch
[Lady_Aleena]: marioroy, that makes kinda makes sense.
[Discipulus]: yes i can survive also in younger town.. but when i passed i saw many strange letters..

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2017-04-23 20:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.