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

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.

Replies are listed 'Best First'.
Re^5: Couldn't create file parser context for file "somename.xml"
by ikegami (Patriarch) on Dec 31, 2009 at 20:24 UTC
    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??
        Yes but you don't pass the name of that directory to XML::LibXML.