RSS 提要访问 <a> 个元素

RSS feed accessing <a> elements

我需要帮助来显示来自这个 XML 区块的内容:

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
 <p>We are excited to announce that the <a href="https://world.phparch.com/call-for-speakers/">Call for Speakers</a> has opened for <a href="https://world.phparch.com">php[world] 2016</a>.
 </p>
 <p>Now in its 3rd year, <a href="https://world.phparch.com">php[world]</a> is the conference designed to bring the entire world of PHP together in one place, with dedicated tracks for the biggest applications and frameworks in the PHP community such as WordPress, Drupal, Magento, Joomla!, Symfony, Zend Framework, CakePHP, and Laravel.
 </p>
 <p>We need to hear from you what you want to speak about though.  Talks that fit any of those frameworks or are related to PHP development are all welcome.  We offer a comprehensive speakers package to make sure that our presenters aren't put out financially for the event, including:
 </p>
 <ul>
 <li>Airfare coverage (0 domestic, 00 international)</li>
 <li>Hotel room (1 night + 1 per accepted talk)</li>
 <li>Free ticket to the conference</li>
 <li>Most meals included!</li>
 </ul>
 <p>Don't hesitate, our <a href="https://world.phparch.com/call-for-speakers/">Call for Speakers</a> is only open for 3 weeks and closes on June 24th, 2016.  So get those submissions in soon, we look forward to <a href="https://world.phparch.com/call-for-speakers/">hearing from you</a>!</p>
</div>

我无法显示 p XML 元素中的元素, 感谢您的帮助。

尽管根 div 的所有子项都没有前缀,但它们都在指定其属性的名称空间中。因此,您不能以通常的方式引用它们

对于 DomDocument,代码可能是:

$xml = new DomDocument();
$xml->loadXML($string); 
$xp = new DomXpath($xml);
$xp->registerNamespace('o', "http://www.w3.org/1999/xhtml");

foreach($xp->query('//o:p/o:a') as $a) 
     echo $a->nodeValue . "\n";

demo

或者使用 SimpleXML 这样:

$xml = simplexml_load_string($string);
$xml->registerXPathNamespace('o', "http://www.w3.org/1999/xhtml");
foreach($xml->xpath('//o:p/o:a') as $a) 
     echo $a . "\n";

demo