How to get image element on XML document with PHP? -


i'm trying thumbnail links like:

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

but reason getelementsbytagname doesn't return 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 tried

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

which 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 , white today ❤️                             [pubdate] => fri, 08 sep 2017 20:04:02 +0000                             [guid] => https://www.pinterest.com/pin/209628557639623067/                         ) 

i have looked around hours trying different things, reason still doesn't work.

this fetches images descriptions of rss channels.

you can try :

<?php  $xml=simplexml_load_file("https://www.pinterest.co.uk/sucastro/animals.rss"); foreach ($xml->channel->item $item) {     preg_match('/<img.+src=[\'"](?p<src>.+?)[\'"].*>/i', $item->description, $image);     echo($image['src']);     echo "<br/>"; }  ?> 

output :

https://i.pinimg.com/236x/38/8f/c9/388fc91621d9d12db3d1211b39ab0fc1--flying-dog-pure-joy.jpg https://i.pinimg.com/236x/d7/1f/dc/d71fdc7f19d8c4b896840e4d8c65642f.jpg https://i.pinimg.com/236x/94/2a/fb/942afb5bab44f6f3b4b9ea4f35690c54--national-forest-cute-photos.jpg https://i.pinimg.com/236x/cc/3c/26/cc3c2658f23571a8eb34a0e34d71e80a--majestic-animals-lion-cub.jpg https://i.pinimg.com/236x/98/1f/c6/981fc6e5e1e332e0067c1b6748fce20a--swan-lake-birds-.jpg https://i.pinimg.com/236x/86/90/8d/86908dd2ce9b8c73648cdcbc5d3325e1--white-bunnies-white-rabbits.jpg https://i.pinimg.com/236x/e0/7b/ce/e07bcea2ec026b5900afd0dc0c35ef71--autumn-leaves-west-highland-terrier.jpg https://i.pinimg.com/236x/8f/87/e9/8f87e95b0384a0f227c9078d053cc202--new-friends-my-friend.jpg https://i.pinimg.com/236x/5e/8f/3b/5e8f3bc079c7617d8cf3a91568f402cd--love-my-dog-puppy-love.jpg https://i.pinimg.com/236x/9f/6a/79/9f6a7948c1cf3d1fbc067d52691bbc7d--water-fountains-bird-baths.jpg https://i.pinimg.com/236x/07/09/d0/0709d0b16178da14facd8401a8472a3d--dachshund-humor-dapple-dachshund.jpg https://i.pinimg.com/236x/2e/c7/af/2ec7af9628a30ec3901c3d14d2b6dc08--animal-portraits-animals-photos.jpg https://i.pinimg.com/236x/06/2e/4b/062e4b396631ae6fc52a64c2f32d8022--cat-whiskers-exotic-cats.jpg https://i.pinimg.com/236x/5e/5c/d6/5e5cd648d4efb29b82607445b795d357--teacups-tea-time.jpg https://i.pinimg.com/236x/dc/30/ce/dc30ce6b41970dc93f1a3607cb48ab2a--pretty-birds-beautiful-birds.jpg https://i.pinimg.com/236x/80/63/e1/8063e102ba108b0f6531065bdf50687c--bear-costume-the-zoo.jpg https://i.pinimg.com/236x/c6/f3/1e/c6f31efadca1b2f71b898a85c46a6f87--baby-polar-bears-panda-bears.jpg https://i.pinimg.com/236x/c2/13/c3/c213c317cc750ac5fef00c4ebd1a1b71--elephant-love-baby-elephants.jpg https://i.pinimg.com/236x/49/75/d8/4975d85611c291c50db1ee57f6018bef.jpg https://i.pinimg.com/236x/6b/cd/35/6bcd353ac7250d4159d3c74fe0d75747--beautiful-swan-beautiful-birds.jpg https://i.pinimg.com/236x/1f/fa/4c/1ffa4c7d4f977a9c43c5655a4a3ea0ab--fox-baby-pet-fox.jpg https://i.pinimg.com/236x/1c/9e/e1/1c9ee1aba651fde0473a4abcc8cab6c4--baby-cheetahs-travel-photography.jpg https://i.pinimg.com/236x/fd/cd/40/fdcd40daae027c7f51298a543a015791--baby-caracal-baby-bobcat.jpg https://i.pinimg.com/236x/cc/75/b7/cc75b77d9cea128fcab6daa1d57826af--leopard-animal-baby-leopard.jpg https://i.pinimg.com/236x/3c/93/29/3c9329976aa40675483e026f4ac5baa6--animaux-totems-can-to.jpg 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -