Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: parse xml and trigger function modules.

by Anonymous Monk
on Apr 09, 2012 at 04:25 UTC ( #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.
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2014-11-27 00:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (177 votes), past polls