我有RSS阅读器,想删除一行中有特定词语的行。
例如,我想删除包含该字的行#34;此文本来自"
我的代码:
$xml=("http://rss-feed");
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
$channel=$xmlDoc->getElementsByTagName('channel')->item(0);
$channel_title = $channel->getElementsByTagName('title')
->item(0)->childNodes->item(0)->nodeValue;
$channel_link = $channel->getElementsByTagName('link')
->item(0)->childNodes->item(0)->nodeValue;
$channel_desc = $channel->getElementsByTagName('description')
->item(0)->childNodes->item(0)->nodeValue;
//echo("<p><a href='" . $channel_link
// . "'>" . $channel_title . "</a>");
//echo("<br>");
//echo($channel_desc . "</p>");
$x=$xmlDoc->getElementsByTagName('item');
for ($i=0; $i<=20; $i++) {
$item_title=$x->item($i)->getElementsByTagName('title')
->item(0)->childNodes->item(0)->nodeValue;
$item_link=$x->item($i)->getElementsByTagName('link')
->item(0)->childNodes->item(0)->nodeValue;
$item_desc=$x->item($i)->getElementsByTagName('description')
->item(0)->childNodes->item(0)->nodeValue;
echo ("<p><a target=_blank href='" . $item_link
. "'>" . $item_title . "</a>");
echo ("<br>");
echo ($item_desc . "</p>");
echo ("<hr>");
}