[phpXML] Re: [phpXML] [xpath.class.php] Question (stupid one ?)
Brought to you by:
bs_php,
nigelswinson
From: <nig...@us...> - 2001-10-08 16:53:17
|
> I'm still fighting with xpath.class.php > > I don't buy the fact the problems I have with xpath.class.php are related > to my ISP because xml.php 1N6 works like a charm) and I use it a lot. Yeah, I'm not that happy with it as the reason either... > So I'd to have a detailed explanation of the meaning of the following error : > phpXML error: While parsing an XPath expression there was an error in the > predicate "Gerhard", because it was the null string. If you wish to seach > for the empty string, you must use ''. > > > Context > ======== > xpath.class.php > > Line 1996 > if (ereg('^\w*$', $predicate)) { > // Display an error message. > $this->_displayError("While parsing an XPath expression ". > "there was an error in the predicate \"$predicate\", ". > "because it was the null string. If you wish to seach ". > "for the empty string, you must use ''."); > return FALSE; > } > > The error occurs when I try to use xpath.class.php with government example > in this case searching for Gerhard:: > > phpXML error: While parsing an XPath expression there was an error in the > predicate "Gerhard", because it was the null string. If you wish to seach > for the empty string, you must use ''. > > Question > =========== > How can the string "Gerhard" be a "null string" ??? I only know how to use perl regexes, and have still not found a decent POSIX reference despite 1 hour of searching the other day. Run the following script: <?php echo "With 'Gehard'<br>\n"; echo 'result from ereg (using POSIX regexes) is:'.(ereg('^\w$',"Gerhard") ? "true" : "false")."<br>\n"; echo 'result from preg_match (using PERL regexes) is:'.(preg_match("/^\s*$/", "Gerhard") ? "true" : "false")."<br>\n"; echo "With ''<br>\n"; echo 'result from ereg (using POSIX regexes) is:'.(ereg('^\w$',"") ? "true" : "false")."<br>\n"; echo 'result from preg_match (using PERL regexes) is:'.(preg_match("/^\s*$/", "") ? "true" : "false")."<br>\n"; ?> I get an output of: With 'Gehard' result from ereg (using POSIX regexes) is:false result from preg_match (using PERL regexes) is:false With '' result from ereg (using POSIX regexes) is:false result from preg_match (using PERL regexes) is:true Which shows to me that the regex is wrong. So change this line: if (ereg('^\w*$', $predicate)) { to: if (preg_match("/^\s*$/, $predicate)) { And let us all know if it works. Nigel -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |