2012-11-05 36 views
0

我正在嘗試使用Feedburner中使用來自Twitter的RSS源(即將離開一年的RSS源),但是xml中的一行代碼導致了feedburner中的解析錯誤。我認爲這是如何在php中搜索和刪除字符串

的xmlns:嘰嘰喳喳=「http://api.twitter.com」

我正在尋找一種方式讓這些信息在某種程度上Feedburner的,它喜歡的:即PHP包括RSS XML頁面的內容在我自己的網站上的xml(刪除了違規字符串)。包括xml內容是小菜一碟 - 我需要的只是一段代碼來說明iff字符串片段== xmlns:twitter="http://api.twitter.com"然後字符串frament =「」。

任何人的任何想法的語法?

回答

2

您可以str_replace嘗試:

str_replace('xmlns:twitter="http://api.twitter.com"', '', $string); 

此外,您還可以嘗試urlencodehttp://api.twitter.com

2

或者,你可以使用的preg_replace功能: http://php.net/manual/en/function.preg-replace.php

<?php 
$string = 'string to be searched'; 
$pattern = 'a particular pattern'; 
$replacement = ''; //deletion 
echo preg_replace($pattern, $replacement, $string); 
?>