簡體   English   中英

從xml移除子節點

[英]Remove child node from xml

我正在從mysql數據生成xml代碼。 但它會在每個節點之前重復生成項目節點。 請給我有關如何刪除項目節點的解決方案。 我的代碼是。任何幫助將不勝感激。

<?php
include("config.php");
header('Content-type: text/xml');
include 'XMLParser.class.php';
$qry = mysql_query("select * from store") or die(mysql_error());
$result = mysql_fetch_array($qry);
$xml = XMLParser::encode($result,'response');
echo $xml->asXML();
?>

輸出是哪個項目節點在每個節點之前重復。 請建議我如何刪除此項目節點:

 <response><item>3</item><id>3</id><item>Oxxo</item><name>Oxxo</name><item>avatar.png</item><image>avatar.png</image><item>ludhiyana</item><address>ludhiyana</address><item>9:00-17:00</item><open_close>9:00-17:00</open_close><item>dfsghxg</item><city>dfsghxg</city><item>465476</item><phone>465476</phone><item>0</item><drop_ins>0</drop_ins><item>500</item><cost>500</cost><item>0</item><include_mats>0</include_mats><item>400</item><mat_fee>400</mat_fee><item>28.6139391,77.20902120000005</item><lat_long>28.6139391,77.20902120000005</lat_long><item>2015-02-03 

15:46:582015-02-03 15:46:5811

mysql_fetch_array接受第二個參數來指示您想要檢索數據的方式(接受的值:MYSQL_ASSOC,MYSQL_NUM和MYSQL_BOTH)。 默認情況下,它同時返回關聯數組索引和數字索引(MYSQL_BOTH)。 您可以使用:

$result = mysql_fetch_array($qry, MYSQL_ASSOC);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM