看板 PHP 關於我們 聯絡資訊
抱歉 新手標題實在不知道該怎下 想請教的是 我有一個資料表 用xml讀取出來 其中我的address 是一個網址 但是給其他網頁使用的時候 顯示出來的卻只是一個字串 想請教一下 是要更改我的格式 還是無法利用xml 去讀取網址(一定會變字串?) 這是我顯示出來的結果 http://ppt.cc/sUj3 以下是我的程式碼 只有部分 function parseToXML($htmlStr) { $xmlStr=str_replace('<','&lt;',$htmlStr); $xmlStr=str_replace('>','&gt;',$xmlStr); $xmlStr=str_replace('"','&quot;',$xmlStr); $xmlStr=str_replace("'",'&#39;',$xmlStr); $xmlStr=str_replace("&",'&amp;',$xmlStr); return $xmlStr; } $query = "SELECT * FROM markers WHERE 1"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } header("Content-type: text/xml"); // Start XML file, echo parent node echo '<markers>'; // Iterate through the rows, printing XML nodes for each while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE echo '<marker '; echo 'name="' . parseToXML($row['name']) . '" '; echo 'address="' . parseToXML($row['address']) . '" '; echo 'lat="' . $row['lat'] . '" '; echo 'lng="' . $row['lng'] . '" '; echo 'type="' . $row['type'] . '" '; echo '/>'; } // End XML file echo '</markers>'; -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 120.101.3.57 ※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1429487003.A.176.html
hareion08: 改用PHP內建的類別來處理XML如何?new DOMDocument(), 04/20 08:24
hareion08: XMLReader() 04/20 08:24
LaPass: 有內建的轉換器,為什麼要自己寫? 04/20 12:22