ankit.tayal560 has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; use Data::Dumper; use XML::DOM; my $parser=new XML::DOM::Parser; my $doc=$parser->parsefile('C:\perl\perl_tests\xmlin.xml') or die$!; my $config=$doc->getElementsByTagName("config"); my $config_attr=$config->getAttribute("logdir"); print("$config_attr");
XML file :<config logdir="var/log/foo/" debugfile="tmp/foo.debug"> <server name ="sahara" osname ="solaris" osversion="2.6"> <address>10.0.0.101</address> <address>10.0.1.101</address>Text </server> <server name="gobi" osname="irix" osversion="6.5"> <address>10.0.0.102</address>text1 </server> <server name="kalahari" osname="linus" osversion="2.0.34"> <address>10.0.0.103</address> <address>10.0.1.103</address>Text2 </server> </config> when I try to run this script I get an error saying : can't locate object method "getAttribute" via package "XML::DOM::NodeList" at C:\perl\perl_tests\xmlin.pl line 10. what is the problem with my script?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: error : can't locate object method "getAttribute" via package XML::DOM::NodeList
by Corion (Patriarch) on Sep 27, 2016 at 08:12 UTC | |
by ankit.tayal560 (Beadle) on Sep 27, 2016 at 08:55 UTC | |
by Corion (Patriarch) on Sep 27, 2016 at 08:59 UTC | |
by ankit.tayal560 (Beadle) on Sep 27, 2016 at 09:11 UTC | |
by Corion (Patriarch) on Sep 27, 2016 at 09:12 UTC | |
|
Re: error : can't locate object method "getAttribute" via package XML::DOM::NodeList
by choroba (Cardinal) on Sep 27, 2016 at 08:45 UTC |