DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> XML學習教程 >> XML詳解 >> 使用PHP 5.0 輕松解析XML文檔(4)
使用PHP 5.0 輕松解析XML文檔(4)
編輯:XML詳解     
行對結果:

  下面是通過函數getSaveData()返回的整個XML數據的數組

Array( [name] => 華聯 [address] => 北京長安街-9999號 [desc] => 連鎖超市 [cat_food] => Array ( [attrs] => Array ( [id] => food ) [goods_food11] => Array ( [name] => food11 [price] => 12.90 [attrs] => Array ( [id] => food11 ) ) [goods_food12] => Array ( [name] => food12 [price] => 22.10 [desc] => Array ( [value] => 好東西推薦 [attrs] => Array ( [creator] => hahawen ) ) [attrs] => Array ( [id] => food12 ) ) ) [cat_1] => Array ( [goods_tel21] => Array ( [name] => tel21 [price] => 1290 [attrs] => Array ( [id] => tel21 ) ) ) [cat_coat] => Array ( [attrs] => Array ( [id] => coat ) [goods_coat31] => Array ( [name] => coat31 [price] => 112 [attrs] => Array ( [id] => coat31 ) ) [goods_coat32] => Array ( [name] => coat32 [price] => 45 [attrs] => Array ( [id] => coat32 ) ) ) [special_hot] => Array ( [attrs] => Array ( [id] => hot ) [goods_0] => Array ( [name] => hot41 [price] => 99 ) ))
  下面是通過setValue()函數,給給根節點添加信息,添加後顯示出結果XML文件的內容

<?XML version="1.0" encoding="GB2312" ?>
<shop> <name>華聯</name> <address>北京長安街-9999號</address> <desc>連鎖超市</desc> <telphone>123456789</telphone> <cat id="food"> <goods id="food11"> <name>food11</name> <price>12.90</price> </goods> <goods id="food12"> <name>food12</name> <price>22.10</price> <desc creator="hahawen">好東西推薦</desc> </goods> </cat> <cat> <goods id="tel21"> <name>tel21</name> <price>1290</price> </goods> </cat> <cat id="coat"> <goods id="coat31"> <name>coat31</name> <price>112</price> </goods> <goods id="coat32"> <name>coat32</name> <price>45</price> </goods> </cat> <special id="hot"> <goods> <name>hot41</name> <price>99</price> </goods> </special></shop>
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved