3
<?php
  $feed = file_get_contents('http://thexmofo.wordpress.com/feed/');
  $xml = new SimpleXMLElement($feed);
  $xml->registerXPathNamespace('media', 'http://thexmofo.wordpress.com/feed/');
  $images = $xml->xpath('/rss/channel/item/media:content@url');
  var_dump($images);
?>

Can anyone tell my why I'm getting Warning: SimpleXMLElement::xpath() [simplexmlelement.xpath]: Invalid expression followed by bool(false)?

2 Answers 2

4

That XPath expression is invalid, that much we know. Now since you didn't say what you were trying to select, all we can do is randomly guess your intentions, so here's my random guess:

/rss/channel/item/media:content/@url

...assuming you're trying to select all the @url attributes in that feed.

Sign up to request clarification or add additional context in comments.

1 Comment

Josh you guessed... not so randomly since I had made what looks to me like a very close attempt... correctly. Thanks.
1

Well, bool(false) is probably from your var_dump.

Iam not sure if media:content@url is valid xpath...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.