Re: php.XPath class question
Brought to you by:
bs_php,
nigelswinson
From: Nigel S. <nig...@us...> - 2003-04-24 20:20:27
|
Hi Paul, getData() takes: string $xPathQuery xpath to the node - resolves to *one* xpath. So the error message is saying that "//directory[name=help]/logo" matches more than one node (or no node). So it doesn't know which node to return you the data of. Try: $aMatches = $xpath->match("//directory[name='help']/logo"); print_r($aMatches); $logo= $xpath->getData($aMatches[0]); echo $logo; (Note the ' and the call to match before the call to getData). You might get away with: $logo= $xpath->getData("//directory[name='help']/logo"); echo $logo; Cheers Nigel ----- Original Message ----- From: "Paul Arnold" <Pa...@pi...> To: <nig...@us...> Sent: Thursday, April 24, 2003 4:31 PM Subject: php.XPath class question Hi Nigel, I wonder if you can help me at all. If I try to carry out $logo= $xpath->getData("//directory[name=help]/logo"); echo $logo; or $logo= $xpath->getData("//directory[@name=help]/logo"); echo $logo; on the piece of xml below I get the following error: XPath error in XPath.class.php:5061 The supplied xPath '' does not *uniquely* describe a node in the xml document. Is this correct? Is it a bug? Can you tell me how I select the //directory[@name=help]/logo node? <root> <directory name="company"> <logo>images/logo.gif</logo> </directory> <directory name="help"> <logo>images/logohelp.gif</logo> </directory> </root> Kind regards, Paul Arnold Software Engineer Pivetal Ltd. Tel: 023 8021 5302 Email: pa...@pi... |