4
programitically產生
我做PHP編碼使用它的源代碼,我手動複製一個XML文件,它看起來像差異手動複製和PHP
<title type='text'>content I've extracted</title>
<content type='text'>content I've extracted</content>
現在一切都做,當我產生通過PHP編碼的內容,當我嘗試從標題和內容標籤提取的東西輸出不會生成...當我交叉檢查時,我發現PHP生成的文件(源代碼,RSS源)看起來像
<title type=\'text\'>content to be extracted </title>
<content type=\'text\'>content to be extracted</content>
由於存在反斜線,因此無法提取的內容,我想,我正在使用從這些標籤獲取內容
樣本PHP代碼
$titles = $entry->getElementsByTagName("title");
$title = $titles->item(0)->nodeValue;
$descrs = $entry->getElementsByTagName("content");
$descr = $descrs->item(0)->nodeValue;
有人可以請建議我如何進行
這是PHP代碼我用於生成XML
$url='http://gdata.youtube.com/feeds/api/playlists/12345';
$fp = fopen($url, 'r');
$buffer='';
if ($fp) {
while (!feof($fp))
$buffer .= fgets($fp, 1024);
fclose($fp);
file_put_contents('feed.xml', $buffer);
我發現溶液
$buff=stripslashes($buffer);
file_put_contents('ka.xml', $buff);
所以stripslashes()
函數刪除反斜線和它的作品
不要與proken XML進行,並顯示你想要當什麼XML確實沒有幫助。你能告訴我們你是如何創建/獲取這個破碎的XML? – Wrikken 2012-01-27 13:27:51
如果這是你的整個XML文件,那麼我不知道你是如何得到任何工作。你能發佈所有的XML,以及你用來加載XML的代碼嗎? – 2012-01-27 13:28:00