Skip to content

Instantly share code, notes, and snippets.

@EdwardIII
Last active December 31, 2015 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EdwardIII/5bd00190536e0b4f1091 to your computer and use it in GitHub Desktop.
Save EdwardIII/5bd00190536e0b4f1091 to your computer and use it in GitHub Desktop.
<?php
function xpath($doc, $xpath_query){
$xpath = new DOMXPath($doc);
$xpath->registerNamespace("ns", "http://www.opentravel.org/OTA/2003/0");
return $xpath->query($xpath_query);
}
var_dump(xpath($some_existing_doc, '//aNodeThatDefinitelyExists'));
/* Returns:
object(DOMNodeList)#5 (1) {
["length"]=>
int(0)
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment