To run an xpath query on an XML document that has a namespace, the namespace must be registered with SimpleXMLElement::registerXPathNamespace() before running the query. If the XML document namespace does not include a prefix, you must make up an arbitrary one, and then use it in your query.

xpath cannot search through the xml without explicitly specifying a namespace.There are 2 options :1. rename the 'xmlns' into something else to trick xpath into believing that no default namespace is defined.2. register a string as the default namespace and use that string in all your queries. Unfortunatly, an empty space will not work.No other option currently exist until XPath2.0 becomes the default library.

Note that this function does not ALWAYS return an array. It seems that if the specified path is not found in the document, it will return false. You need to check for the false value before using foreach, if you wish to avoid a warning (and often to handle errors or control program flow in this situation).

Seems like this function cannot return the result of XPath string() [1] function. For example if you query xpath("string(a/@b)") you will get bool(false) although the node "a" may have the attribute "b" set to a non-empty string.

I have tried many variations on the embedded single quote (i.e. escape codes) but with no result. W3C offers no explanation either.

In addition, there doesn't seem to be any way of embedding wildcards in the attribute value (you can embed wildcards in the attribute name). Otherwise the following might be a reasonable substitute in this context: