New here? Register and read our Community Rules. Accounts are approved by hand.

XPath problem in PHP

dnwkdnwk Member
edited May 2014 in Help

I am using XPath in PHP to search for 1 information. Every XPath test tool can find the information with that XPath Query. However, PHP doesn't deliver it. Anyone know what's the problem?
Thanks

Here is the XML Source: http://pastebin.com/8ykGpASr

And here is my PHP code for Xpath

$xml = new SimpleXMLElement($html); $xml->registerXPathNamespace('ssopenurl', 'http://xml.serialssolutions.com/ns/openurl/v1.0'); $url = $xml->xpath('//ssopenurl:url[@type="article"]'); var_dump($url);

Comments

  • nerouxneroux Member

    What does xpath() return? An empty array or false? I tried it and it returns an array with one element.

  • vedranvedran Veteran

    Same here, you probably messed up somewhere before, check if $html is really what's it supposed to be.

  • dnwkdnwk Member

    If I search for other node, it will return fine.

  • dnwkdnwk Member

    Oops. Yes. You are right. $html is not what I though they should be.

Sign In or Register to comment.