Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: XMLin is not identifying the input file name passed to it

by ikegami (Patriarch)
on Nov 08, 2006 at 07:17 UTC ( #582806=note: print w/replies, xml ) Need Help??


in reply to XMLin is not identifying the input file name passed to it

The docs say

If the filename contains no directory components XMLin() will look for the file in each directory in the SearchPath (see "OPTIONS" below) or in the current directory if the SearchPath option is not defined.

The search path is initialized to something based on $0. In this case, it's incorrectly initialized to ['']. Try

$data = $xml->XMLin($file, SearchPath => '.');

Replies are listed 'Best First'.
Re^2: XMLin is not identifying the input file name passed to it
by greatshots (Pilgrim) on Nov 08, 2006 at 07:58 UTC
    thanks a lot for solving this Issue.

    added the working code here.

    #!/usr/bin/perl my $file = shift; use XML::Simple; die "Can't find file \"$file\"" unless -f $file; $xml = new XML::Simple; print "Input file :$file:\n"; # read XML file $data = $xml->XMLin("/full_path_name/$file");

Re^2: XMLin is not identifying the input file name passed to it
by greatshots (Pilgrim) on Nov 08, 2006 at 07:23 UTC
    got the following error
    Code change : $data = $xml->XMLin($file,SearchPath => '.'); OUTPUT Input file :layer.xml: Unrecognised option: SearchPath at parse_report_layerxml.pl line 13

      oops! I meant

      $data = $xml->XMLin($file, SearchPath => ['.']);

      But that's not the error your getting. What version are you using? It might have been called searchpath in your version.

      $data = $xml->XMLin($file, searchpath => ['.']);
        or simply give the full path for the $file ...

        -- Hofmator

        Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

        I assume you are asking about my perl version
        Summary of my perl5 (revision 5.0 version 6 subversion 1) configuratio +n: Platform: osname=hpux, osvers=11.00, archname=PA-RISC1.1-thread-multi uname='hp-ux llbertha b.11.00 u 9000800 2002402864 unlimited-user +license '
        I have no idea on how to check the module version.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2023-09-25 06:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?