Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOMXpath

Status
Not open for further replies.

tweenerz

Programmer
Mar 25, 2002
202
US
I need to do use the evaluate function in teh DOMXpath, but the attribute I am trying to access has a colon in it, and I cant figure out how to get it. I can access all the attributes with just letters, but it doens tfind this one:

Code:
$xpath = new DOMXPath($doc);
$entries = $xpath->evaluate("wsu:Id", $doc);

the xml file contains this, which I am trying to find:
Code:
<wsu:Timestamp wsu:Id="Timestamp-2f00e1cf-15bb-437f-b80c-e71bb3a89348">

So I need it to return a nodelist with Timestamp-2f00e1cf-15bb-437f-b80c-e71bb3a89348 in it.

Ideas?
 
By the info so posted, I can only deduce there lacks a good deal of the understanding of what-about the namespace. Under this assumption, I can suggest this xpath so that you can see directly the results.
[tt]
$sxpath = "//*[local-name()='Timestamp']/@*[local-name()='Id']";
$entries = $xpath->evaluate($sxpath, $doc);
foreach($entries as $entry) {
echo $entry->nodeValue."<br />\n";
}
[/tt]
With all the elements appeared in the path, you have to fill in the gap by reading the documentation and what's about the namespace and xpath technology.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top