biswanath_c has asked for the wisdom of the Perl Monks concerning the following question:


Hi,


I was trying to parse and search a node in an xml file. I got an error while executing the "findnodes" method on the root element. The error message: "xmlXPathCompiledEval: evaluation failed"

Could any of you help me resolve this error please? I know for sure that the XML doc is a valid xml and the node that I am searching for exists for sure!

I found another weird behavior! When i hardcode the node name in "findnodes" call, the program runs successfully! But when i pass the node name as a variable, i get the error that i mentioned earlier!! Why would that be?!!



  • Comment on Error while parsing an XML file using XML::LibXML ...

Replies are listed 'Best First'.
Re: Error while parsing an XML file using XML::LibXML ...
by ikegami (Patriarch) on Oct 14, 2009 at 23:58 UTC

    Seeing as findnodes has absolutely no idea whether the string you gave it was hardcoded or not, and since you claim that is the only difference, that leaves only one possibility: You're passing a different string than the one you had hardcoded.

    Most likely, the variable to which you alluded doesn't contain what you think it does. But since you provided no code, there's no way to know.

      that's the weird part! I understand your comment; but I printed out the variable just before calling findnodes (the line of code that breaks) - it's EXACTLY the same as the hard-coded value that I tried in find nodes which succeeds! I know it sounds weird, but that's why i am confused too!

        Either it isn't exactly the same (trailing whitespace?) or something else is different.