Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

XML::XPath question

by anniyan (Monk)
on Nov 17, 2005 at 11:24 UTC ( #509361=perlquestion: print w/ replies, xml ) Need Help??
anniyan has asked for the wisdom of the Perl Monks concerning the following question:

The following code gives error saying stats.dtd not present. Yes i am not having any dtd for that xml. I am using that xml just for testing, my xml input will be always parsed before using this code. How could i use the below code without dtd and is there any way to ignore that dtd parse?

use strict; use XML::Twig; use XML::XPath; use XML::XPath::XMLParser; my $xp = XML::XPath->new(filename => '1.xml'); my $nodeset = $xp->find('title'); my $size = $nodeset->size; print "$size\n"; foreach my $node ($nodeset->get_nodelist) { print "found\n\n",XML::XPath::XMLParser::as_string($node),"\n\n"; }
<?xml version="1.0"?> <!DOCTYPE stats SYSTEM "stats.dtd"> <stats><title id="1">testing<name><snm>Houston</snm>, <fnm>Allan</fnm> +</name><g>69</g><ppg>20.1</ppg><rpg>3.4</rpg><apg>2.8</apg><blk>14</b +lk></title> <title><name>Sprewell, Latrell</name><g>69</g><ppg>19.2</ppg><rpg>4.5< +/rpg><apg>4.0</apg><blk>15</blk></title> <title><name>Ewing, Patrick</name><g>49</g><player><name>aaa</name></p +layer><ppg>14.6</ppg><rpg>10.0</rpg><apg>1.0</apg><blk>68</blk></titl +e> <title><name1>Raja m</name1><g>49</g><player><name>aaa</name></player> +<ppg>14.6</ppg><rpg>10.0</rpg><apg>1.0</apg><blk>68</blk></title> </stats>

Regards,
Anniyan
(CREATED in HELL by DEVIL to s|EVILS|GOODS|g in WORLD)

Comment on XML::XPath question
Select or Download Code
Re: XML::XPath question
by pajout (Curate) on Nov 17, 2005 at 11:27 UTC
    delete <!DOCTYPE stats SYSTEM "stats.dtd"> from your testing file...

      pajout thanks for the suggestion, now it works, but without deleting that in xml file, is there any other way to do that?

      Regards,
      Anniyan
      (CREATED in HELL by DEVIL to s|EVILS|GOODS|g in WORLD)

        Create empty file stats.dtd on the same directory as your xml file.
        I am not very familiar with XML::XPath, but this may work...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2014-09-01 09:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (299 votes), past polls