perl, xpath and dtd

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi all,
first of all I'm non a perl-expert: I just code in perl some times...

I'm coding a tool to analyze the xml created by the websphere
performance servlet but I'm having problems with dtd documents...

This is my code:

use XML::XPath;
use XML::XPath::XMLParser;
use LWP::UserAgent;
use HTTP::Request;

my $ua = LWP::UserAgent->new;
my $url ="http://address";
my $jdbc_driver = "DB2 Universal JDBC Driver Provider";

my $req = HTTP::Request->new(GET => $url);
my $response = $ua->request($req);
my $content = $response->content();

my $xpath="/PerformanceMonitor/Node/Server/Stat/Stat/CountStatistic/

if ($response->is_success) {
        $xp = XML::XPath->new(ioref => $content );
        my $nodeset = $xp->findnodes($xpath);
        foreach my $node ($nodeset->get_nodelist){
                print XML::XPath::XMLParser::as_string($node);

I get this output

[mstrullato@vm01 ~]$ perl ./
404 File `/wasPerfTool/dtd/performancemonitor.dtd' does not exist
Handler couldn't resolve external entity at line 8, column 160, byte
error in processing external entity reference at line 8, column 160,
byte 703:
<!--    not published or otherwise divested of its trade secrets,
irrespective  -->
<!--    of what has been deposited with the U.S. Copyright
Office.              -->
Quoted text here. Click to load it

<PerformanceMonitor responseStatus="success" version="">
 at /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/XML/ line 187

I can see that the problem is the dtd document that is not found: the
code is looking to the dtd into filesystem and not from the correct

Could you help me?
Hou should I change my code?



Re: perl, xpath and dtd

Quoted text here. Click to load it


Quoted text here. Click to load it

Well, XML::XPath::XMLParser subclasses XML::Parser.
You ought to read up on DTD inclusion and your specific errors in the
XML::Parser docs.


Site Timeline