Page 1 of 1

xpath_eval problems

Posted: Thu Mar 15, 2007 8:17 am
by lettie_dude
Hi I have a problem with some code that I need to implement for a news feed. The feed is xml from a news source site. The problem I have is that the xpath_eval function does not seem to be reading the dom object.

I am running on php 4.4.1 on a Linux system. domxml is enabled along with XPath support.

Apparently the code should work with php 4 and has worked for other users of the news feed. The guys providing the code seem to think it may be a problem with the version of the DOM/XML API Version which my hosts are using version: 20020815

I get the following error message when trying to run the code:

Warning: xpath_eval(): Invalid expression in /path of file on line 29

Warning: xpath_eval(): xmlXPathEval: evaluation failed in /path of file on line 29
Article found: 0

Any help much appreciated.


Code is as follows:

Code: Select all

$dataFile = fopen ('http://newssiteurl.co.uk/?c21c0905-b9ca-43ee-87be-7e4308406da6','r')
or die("Error Loading XMl");

if ( $dataFile )
{
while (!feof($dataFile))
{
$buffer .= fgets($dataFile, 4096); 
}
fclose($dataFile);
}
else
{
die( "fopen failed for $filename" ) ;
}

// Loading xml into a DOM object.
$dom = domxml_open_mem($buffer);
$xpc = xpath_new_context($dom);

// Selecting nodes matching node "Article" using xpath_eval command and passing it the xpath context
$nodes = xpath_eval($xpc, "//Article/");

Posted: Thu Mar 15, 2007 8:26 am
by volka
lettie_dude wrote://Article/
remove the trailing /

xpath probs

Posted: Thu Mar 15, 2007 8:40 am
by lettie_dude
Many thanks volka seems to have done the trick.

Cheers