views:

178

answers:

2
<?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)?

+1  A: 

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

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

henchman
+1  A: 

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.

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