Я искал здесь решение своей проблемы, но ничего не работает :(
У меня есть следующий код
<?php
$rss = new DOMDocument();
$rss->load('http://thelostgirl2014.wordpress.com/feed/');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node)
{
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
'content' => $node->getElementsByTagName('encoded')->item(0)->nodeValue,
'comments' => $node->getElementsByTagName('comments')->item(0)->nodeValue,
'photos' => $node->getElementsByTagNameNS('http://thelostgirl2014.wordpress.com/feed/', 'content')->item(0),
);
array_push($feed, $item);
}
$limit = 3;
for($x=0;$x<$limit;$x++)
{
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
$link = $feed[$x]['link'];
$description = $feed[$x]['desc'];
$content = $feed[$x]['content'];
$comments = $feed[$x]['comments'];
$photos = $feed[$x]['photos'];
$date = date('l F d, Y', strtotime($feed[$x]['date']));?>
<div class="feed">
<div class="feed-title">
<a href="<?php echo $link?>" title="<?php echo $title?>"><?php echo $title?></a>
</div>
<div class="feed-date">
<small><em>Posted on <?php echo $date?></em></small>
</div>
<div class="feed-description">
<?php echo $photos?>
</div>
</div><?php
}?>
и он извлекает основные значения узла, но я не могу получить значения пространства имен.
Я пытаюсь получить URL-адрес мультимедиа, чтобы отображать изображения на моей php-странице, но текущий код
'photos' => $node->getElementsByTagNameNS('http://thelostgirl2014.wordpress.com/feed/', 'content')->item(0),
ничего не возвращает :(
вот фрагмент из блога, в котором я пытаюсь восстановить данные
<item>
<title>Achievements</title>
<link>http://thelostgirl2014.wordpress.com/2014/01/13/achievements/</link>
<comments>http://thelostgirl2014.wordpress.com/2014/01/13/achievements/#comments</comments>
<pubDate>Mon, 13 Jan 2014 03:20:32 +0000</pubDate>
<dc:creator><![CDATA[thelostgirl2014]]></dc:creator>
<category><![CDATA[Uncategorized]]></category>
<guid isPermaLink="false">https://thelostgirl2014.wordpress.com/?p=8</guid>
<description><![CDATA[Well, in the last few months I have achieved so much…from joining a cruiseship to simply eating prawns!! I have never been a prawn fan, never liked the look of them so never tried them! But today, at Mozarts Restaurant in Funchal, Madeira I had a fresh mushroom and prawn risotto which was delicious! To […]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelostgirl2014.wordpress.com&blog=62611577&post=8&subd=thelostgirl2014&ref=&feed=1" width="1" height="1" />]]></description>
<content:encoded><![CDATA[<p><a href="http://thelostgirl2014.files.wordpress.com/2014/01/20140113-031825-am.jpg"><img src="http://thelostgirl2014.files.wordpress.com/2014/01/20140113-031825-am.jpg?w=696" alt="20140113-031825 am.jpg" class="alignnone size-full" /></a></p>
<p>Well, in the last few months I have achieved so much…from joining a cruiseship to simply eating prawns!! </p>
<p>I have never been a prawn fan, never liked the look of them so never tried them!<br />
But today, at Mozarts Restaurant in Funchal, Madeira I had a fresh mushroom and prawn risotto which was delicious! </p>
<p>To me this is a massive step for me, I have always been afraid of trying new food but seeing as I’m away I’m keen to try new things…so prawns are my latest thing…<br />
The best thing was…the three course meal came with free champagne and wine woohoo!! Bonus!! €37 well spent me thinks!!</p><br /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thelostgirl2014.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thelostgirl2014.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelostgirl2014.wordpress.com&blog=62611577&post=8&subd=thelostgirl2014&ref=&feed=1" width="1" height="1" />]]></content:encoded>
<wfw:commentRss>http://thelostgirl2014.wordpress.com/2014/01/13/achievements/feed/</wfw:commentRss>
<slash:comments>0</slash:comments>
<georss:point>32.642638 -16.923540</georss:point>
<geo:lat>32.642638</geo:lat>
<geo:long>-16.923540</geo:long>
<media:content url="http://2.gravatar.com/avatar/5f747606b6bc78986250229230fe693f?s=96&d=identicon&r=G" medium="image">
<media:title type="html">thelostgirl2014</media:title>
</media:content>
<media:content url="http://thelostgirl2014.files.wordpress.com/2014/01/20140113-031825-am.jpg" medium="image">
<media:title type="html">20140113-031825 am.jpg</media:title>
</media:content>
</item>
любая помощь, чтобы вернуть URL-адрес мультимедиа, была бы отличной, Люк