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. | [reply] |
| [reply] |
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";
}
| [reply] [d/l] |
| [reply] |