Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


XPath problem in PHP
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

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.