Grouptags


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grouptags
# 1  
Old 05-18-2009
Grouptags

Hi All,

I have parsed an xml file and the resulting output is as follows

RT
=> {
'List' => {
'String' => [abcd
efgh
]

RT!
=> {
'List' => {
'String' => [
pqrs
lmno
]


I am trying to get the String values under RT and here is the code i am using

Code:
my $data = XMLin("output.xml", GroupTags=>{RequestedTerminations=>'String'});
# print output
print Dumper($data);


However, it doesnt seem to work and i get the following error
Code:
Undefined subroutine &main::XMLin called at dump.pl line 15.

Appreciate your help with this

Last edited by Yogesh Sawant; 05-19-2009 at 02:50 AM.. Reason: added code tags
# 2  
Old 05-19-2009
have you written this in your script:
Code:
use XML::Simple;

make sure that CPAN module XML::Simple is installed:
Code:
perl -e 'use XML::Simple;'

# 3  
Old 05-19-2009
Question

Yogesh,

Thanks for the response. I have defined use XML::Simple in my script.

I was able to parse the xml file successfully using that. However when i try to get values for paricular fields i am having problems. I also tried using keyattr as follows

my $data = XMLin('dump.xml', KeyAttr=>{RT =>"List"});
print $data->{RT}=>{List}->{String};

I get this error: Bareword "MapEntry" not allowed while "strict subs" in use at dump.pl line 22.
Execution of dump.pl aborted due to compilation errors.

String has more that one value. Could that be a problem?

Appreciate any help.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question