Re: XPATH question
Brought to you by:
bs_php,
nigelswinson
From: Nigel S. <nig...@us...> - 2003-08-10 20:27:23
|
Sorry this reply is so late... it's embarrasing. I read it hoping = someone else would reply cos I was busy, and then when I wasn't busy = your question had dropped off the radar :o( I am new to this class so please do not laugh if the question is = elementary. I am trying to user the following string as the query:=20 require_once("XPath.class.php");=20 $userID=3D'yyy';=20 $password=3D'xxx';=20 $url=3D"docs/userProfile.xml";=20 $xpath =3D new XPath($url);=20 $query =3D "/userProfiles/userProfile/general/userID=3D'$userID' AND = /userProfiles/userProfile/general/password=3D'$password'";=20 $tree =3D $xpath->exportAsXml($query);=20 and I am keep getting the error:=20 Notice: Undefined index: = /userProfiles/userProfile/general/userID=3D'yyy' AND = /userProfiles/userProfile/general/password=3D'xxx' in c:\program = files\apache group\apache\htdocs\plms\XPath.class.php on line 1235=20 Please help!=20 The exportAsXml() function takes as an arugment an "Absolute XPath". = This means that it must be the fully qualified address of a node in the = XML document. In the documentation introduction it describes this as: | AbsoluteXPath: (xPath, xPathSet) | A absolute XPath is a string. It 'points' to *one* node in the = XML-document. We use the | term 'absolute' to emphasise that it is not an xPath-query (see = xPathQuery). A valid xPath=20 | has the form like '/AAA[1]/BBB[2]/CCC[1]'. Usually functions that = require a node (see Node)=20 | will also accept an abs. XPath. So what you probably want to do instead is: require_once("XPath.class.php");=20 $userID=3D'yyy';=20 $password=3D'xxx';=20 $url=3D"docs/userProfile.xml";=20 $xpath =3D new XPath($url);=20 $query =3D "/userProfiles/userProfile/general/userID=3D'$userID' AND = /userProfiles/userProfile/general/password=3D'$password'";=20 $aMatches =3D $xpath->match($query); foreach($aMatches as $Match) { echo htmlspecialchars($xpath->exportAsXml($Match));=20 } Cheers Nigel |