Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: XML parser unable to open file

by afoken (Chancellor)
on Nov 11, 2020 at 12:08 UTC ( [id://11123583]=note: print w/replies, xml ) Need Help??


in reply to XML parser unable to open file

I am trying to parse XML files using the XML parser but it fails with the error when the Couldn't open /path to file.xml : No such file or directory at /usr/local/share/perl5/XML/Parser/PerlSAX.pm line 146.

The xml files does exist in the mentioned location.

This is how I am calling the my $parser = XML::Parser::PerlSAX->new( Handler => $RespHandler ); $parser->parse(Source => { SystemId => $ResponseXML });

I don't see any filename in the code fragment you posted. I guess it is hidden in $ResponseXML.

Anyway, try to print out the filename right before calling $parser->parse() to see if your idea of the filename and the filename actually used are the same. If you have no better idea, add

use Data::Dumper qw();

to the top of your script and

print Data::Dumper->new([$ResponseXML],['ResponseXML'])->Useqq(1)->Dum +p(),"\n";

right before $parser->parse(). Running your script will give you debug output similar to this:

$ResponseXML = { "Other" => [ "stuff", "may also", "appear" ], "filename" => " /opt/XML/otherfile.xml\n" };

Note that in my example, I added some common errors: leading space, trailing newline, different directory, different filename.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11123583]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-26 00:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found