Php 显示wordpress rss源中的媒体文件

Php 显示wordpress rss源中的媒体文件,php,wordpress,rss,Php,Wordpress,Rss,我正在使用PHP解析一个普通wordpress.com博客的rss提要,以便在我的网站上显示文章的预览 它正确显示:标题、说明和发布日期。但我也想展示每个帖子的图片。如果我打开提要的URL,就会看到一个带有“媒体文件链接”的图表,但我不知道如何访问这些链接 你有什么建议吗 这是我正在使用的代码: <?php $xml=("http://testmustard.wordpress.com/feed/"); $xmlDoc = new DOM

我正在使用PHP解析一个普通wordpress.com博客的rss提要,以便在我的网站上显示文章的预览

它正确显示:标题、说明和发布日期。但我也想展示每个帖子的图片。如果我打开提要的URL,就会看到一个带有“媒体文件链接”的图表,但我不知道如何访问这些链接

你有什么建议吗

这是我正在使用的代码:

<?php

            $xml=("http://testmustard.wordpress.com/feed/");

            $xmlDoc = new DOMDocument();

            $xmlDoc->load($xml);

            $items=$xmlDoc->getElementsByTagName('item');
            $max_items= 15;

        ?>      

        <?php foreach( $items as $i => $item ):?>


        <?php
            if($i>=$max_items) break;

            $title = $item->getElementsByTagName( "title" )->item(0)->nodeValue; 
            $description = $item->getElementsByTagName( "description" )->item(0)->nodeValue; 
            $data = $item->getElementsByTagName( "pubDate" )->item(0)->nodeValue;
        ?>
            <div class="posts">
                <div class="rssentry">
                    <h2><?php echo $title?></h2>
                    <div class="rsscontent"><?php echo html_entity_decode($description)?></div>
                    <div class="metadata"><?php echo $data?></div>
                </div>              
            </div>
        <?php endforeach;?>
        </div>  
load($xml);
$items=$xmlDoc->getElementsByTagName('item');
$max_项目=15;
?>      
非常感谢您的帮助

PHP

<?php

$maxItems = 15;

$Document = new DOMDocument();
$Document->load('http://testmustard.wordpress.com/feed/');

$NodeList = $Document->getElementsByTagName('item');

$i = 0;
foreach ($NodeList as $Node) {
    if ($i++ >= $maxItems) {
        break;
    }

    $media = $Node->getElementsByTagNameNS('http://search.yahoo.com/mrss/', 'content');
    if ($media->length > 0) {
        $imageUrl = $media->item(0)->getAttribute('url');
        echo "$imageUrl\n";
    } else {
        echo "No media:content\n";
    }
}

RSS提供了它,但我不知道如何访问它