Quantcast
Channel: How to get image element on XML document with PHP? - Stack Overflow
Viewing all articles
Browse latest Browse all 4

How to get image element on XML document with PHP?

$
0
0

I'm trying to get the thumbnail links like:

https://i.pinimg.com/236x/38/8f/c9/388fc91621d9d12db3d1211b39ab0fc1--flying-dog-pure-joy.jpg

But for some reason getElementsByTagName doesn't return what I wanted.

$newdom=new DOMDocument();$xml=simplexml_load_file("https://www.pinterest.co.uk/sucastro/animals.rss");$newdom->loadXML($xml);$out=$newdom->getElementsByTagName('img');print_r($out);

I also tried

$out=$newdom->channel->item->description->getElementsByTagName('img');

which also failed.

SimpleXMLElement Object(    [@attributes] => Array        (            [version] => 2.0        )    [channel] => SimpleXMLElement Object        (            [title] => ANIMALS            [link] => https://www.pinterest.com/sucastro/animals/            [description] => SimpleXMLElement Object                (                )            [language] => en-us            [lastBuildDate] => Fri, 48 Jan 2017 33:33:33 +0000            [item] => Array                (                    [0] => SimpleXMLElement Object                        (                            [title] => Hi ladies. Let's pin                            [link] => https://www.pinterest.com/pin/209628557639623067/                            [description] => <a href="/pin/209628557639623067/"><img src="https://i.pinimg.com/236x/38/8f/c9/388fc91621d9d12db3d1211b39ab0fc1--flying-dog-pure-joy.jpg"></a>Hi ladies. Let&#39;s pin GREEN AND WHITE today ❤️                            [pubDate] => Fri, 08 Sep 2017 20:04:02 +0000                            [guid] => https://www.pinterest.com/pin/209628557639623067/                        )

I have looked around for hours trying different things, but for some reason it still doesn't work.


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images