DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> XML學習教程 >> XML詳解 >> 使用PHP 5.0 輕松解析XML文檔(5)
使用PHP 5.0 輕松解析XML文檔(5)
編輯:XML詳解     
etNode()函數,返回某一個分類下的所有商品的信息商品名:

food11
Array( [name] => food11 [price] => 12.90)Array( [id] => food11)商品名:food12
Array( [name] => food12 [price] => 22.10 [desc] => Array ( [value] => 好東西推薦 [attrs] => Array ( [creator] => hahawen ) ))Array( [id] => food12)  下面是通過findNodeByPath()函數,返回某一商品的信息商品名:food11

Array( [name] => food11 [price] => 12.90)Array( [id] => food11)
  下面是通過setValue()函數,給商品"food11"添加屬性, 然後顯示添加後的結果

<?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> <leaveword author="hahawen" date="2004-12-05">這個商品不錯</leaveWord> </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>
  下面是通過removeValue()/removeAttribute()函數,給商品"food11"改變和刪除屬性, 然後顯示操作後的結果

<?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> <leaveword author="hahawen" date="2004-12-05">這個商品不錯</leaveWord> </goods> <goods id="food12"> <name>new food12</name> <price>22.10</price> </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