我已经设法通过CDATA解析以提取相关的img src和textContent,但我想知道是否有一种方法可以在Description标记中检测CDATA
修改:这是我正在使用的代码
$rss = new DOMDocument();
$rss->load($url); // Set the blog RSS feed url here
$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,
'author' => $node->getElementsByTagName('author')->item(0)->nodeValue,
'image' => ''
);
编辑2 - 解决方案使用var_dump我设法找到firstChild->nodeName
包含的cdata信息
if ( $node->getElementsByTagName('description')->item(0)->firstChild->nodeName == '#cdata-section'){}