Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: parse xml and trigger function modules.

by Anonymous Monk
on Apr 09, 2012 at 04:25 UTC ( [id://964079]=note: print w/replies, xml ) Need Help??

in reply to parse xml and trigger function modules.

Hi Monks. I tried several ways to parse the below XML but was not successful in doing

Great, show your efforts :)

  • Comment on Re: parse xml and trigger function modules.

Replies are listed 'Best First'.
Re^2: parse xml and trigger function modules.
by balajinagaraju (Sexton) on Apr 09, 2012 at 04:30 UTC
    I tried it using XML::Simple but this gives me a hash reference which is basically a unsorted datastructure, i used XML::Parser as well but it went above my head.. :-). Now trying to use XML::Twig.This seems to be pretty handy but wanted to gather information on the best available and a easy way to do it.

      XML::Twig is frequently recommended and is well documented with lots of example code. Show us what you have tried and we will help correct your code. You will get much better help and learn a lot more that way than having us write a chunk of code for you.

      True laziness is hard work

        Hi, I tried to work with XML::Twig and was successful upto some extent, but still facing problems in accessing certain areas of my XML.How do i access the steps mentioned in each testcase and there corresponding attributes, the solution is quiet urgent for me, can you please suggest how i can access these elements and attributes.

        use strict; use warnings; use 5.010; use XML::Simple; use XML::MyXML; use XML::Twig; my $twig= new XML::Twig( twig_handlers => { testcase => \&testcase }); # create the twig $twig->parsefile( 'D:\\ABC\\Perl Projects\\DCA.xml'); #$twig->print; my $root= $twig->root; #$root->set_tag( 'html'); $twig->print; my @testcase = $root->children('testcase'); # foreach my $testcase (@testcase) # { $testcase->set_tag('p'); } # turn them into p $twig->print; sub testcase{ my ($twig, $testcase) = @_; print $testcase->field('command6'); print $testcase->att('type'); print "\n"; }

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-23 00:20 GMT
Find Nodes?
    Voting Booth?

    No recent polls found