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". ;-)

In reply to Re: XML parser unable to open file by afoken
in thread XML parser unable to open file by rajaoirshi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.