avi_2009 has asked for the wisdom of the Perl Monks concerning the following question:
Hi guys: I was trying this example but getting this error. syntax error at line 1.column 0.byte 0: query.xml ^ at C:/perl/lib/XML/Parser.pm line 187 Please help. Thanks.use strict; use XML::XPath; use XML::XPath::XMLParser; my $xp = XML::XPath->new( xml => 'query.xml' ); print 'There are ', $xp->find('queries/query')->size, " 'query' nodes. +\n"; foreach my $element (qw/topN layer filter name datatype/) { print "$element: ", ( join ', ', map { XML::XPath::XMLParser::as_string($_) =~ />([^<]*)</ } $xp->find("queries/query/$element")->get_nodelist ), "\n"; } ## end foreach my $element (qw/topN layer filter name datatype/) query.xml <?xml version='1.0'?> <queries> <query> <name>topHosts 20</name> <layer>LINK 20</layer> <topN>20</topN> <datatype>topHosts 20</datatype> <filter></filter> </query> <query> <name>topHosts 120</name> <layer>LINK 120</layer> <topN>120</topN> <datatype>topHosts 120</datatype> <filter></filter> </query> </queries>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: xpath problem
by Fletch (Bishop) on Mar 13, 2009 at 16:20 UTC | |
Re: xpath problem
by toolic (Bishop) on Mar 13, 2009 at 16:21 UTC | |
Re: xpath problem
by mirod (Canon) on Mar 13, 2009 at 17:35 UTC | |
Re: xpath problem
by ramrod (Priest) on Mar 13, 2009 at 16:21 UTC |