in reply to Re^2: Couldn’t create file parser context for file "somename.xml"
in thread Couldn’t create file parser context for file "somename.xml"

I bet you do something silly like `ls` and you don't properly extract the line feeds.

Place the following just before the code you posted:

use Cwd; use Data::Dumper; print("cwd = ", getcwd(), "\n"); print("files:\n", do { local $Data::Dumper::Useqq = 1; Dumper(\@files); });

What do you get?

Replies are listed 'Best First'.
Re^4: Couldn't create file parser context for file "somename.xml"
by laleh-poly (Novice) on Dec 31, 2009 at 20:00 UTC
    Hello, After adding the code proposed I get the following:
    $ perl parseXML.pl "D:\Perl-Implementaion\ParseXM L\test" cwd = /cygdrive/D/Perl-Implementaion/ParseXML files: $VAR1 = [ "bb.xml", "bbCopy.xml" ]; bb.xml className= org.argouml.uml.cognitive.critics.CrClassMustBeAbstract methodName= predicate2(Object,Designer) bbCopy.xml Could not create file parser context for file "bbCopy.xml": No such fi +le or dire ctory at parseXML.pl line 37
    You see both files are there. By the way I do not "ls". To get the files in a directory I have the following in the beginning of my script:
    use XML::LibXML; $ARGV[0] || die; $path=$ARGV[0]; # open the designated directory opendir(DIR, $path); @files = grep(/\.xml$/,readdir(DIR));
    Thanks for helping me.
      You're telling XML::Parser to open
      /cygdrive/D/Perl-Implementaion/ParseXML/bb.xml
      and
      /cygdrive/D/Perl-Implementaion/ParseXML/bbCopy.xml

      but the files you want to open are
      D:\Perl-Implementaion\ParseXML\test\bb.xml
      and
      D:\Perl-Implementaion\ParseXML\test\bbCopy.xml

      Notice the missing "test". Fix:

      my @files = map "$path/$_", grep /\.xml\z/, readdir(DIR);
        Hi, Thanks!!! I added the "map.." part and it worked. But what was wrong with my code? you are telling that I am telling XML::Parser to open
        /cygdrive/D/Perl-Implementaion/ParseXML/bb.xml
        and
        /cygdrive/D/Perl-Implementaion/ParseXML/bbCopy.xml
        But I pass the address of the directory in which the files are located as a parameter to my script:
        perl parseXML.pl "D:\Perl-Implementaion\ParseXML\test"
        So what is wrong in this??