文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>MSXML2.DOMDocument.3.0从XML中读取数据

MSXML2.DOMDocument.3.0从XML中读取数据

时间:2009-03-17  来源:zhou2324

先有一个XML数据:

Xml代码
  1. <?xml version="1.0" ?>  
  2. <Order>  
  3.   <Account>9900234</Account>  
  4.   <Item id="1">  
  5.     <SKU>1234</SKU>  
  6.     <PricePer>5.95</PricePer>  
  7.     <Quantity>100</Quantity>  
  8.     <Subtotal>595.00</Subtotal>  
  9.     <Description>Super Widget Clamp</Description>  
  10.   </Item>  
  11.   <Item id="2">  
  12.     <SKU>6234</SKU>  
  13.     <PricePer>22.00</PricePer>  
  14.     <Quantity>10</Quantity>  
  15.     <Subtotal>220.00</Subtotal>  
  16.     <Description>Mighty Foobar Flange</Description>  
  17.   </Item>  
  18.   <Item id="3">  
  19.     <SKU>9982</SKU>  
  20.     <PricePer>2.50</PricePer>  
  21.     <Quantity>1000</Quantity>  
  22.     <Subtotal>2500.00</Subtotal>  
  23.     <Description>Deluxe Doohickie</Description>  
  24.   </Item>  
  25.   <Item id="4">  
  26.     <SKU>3256</SKU>  
  27.     <PricePer>389.00</PricePer>  
  28.     <Quantity>1</Quantity>  
  29.     <Subtotal>389.00</Subtotal>  
  30.     <Description>Muckalucket Bucket</Description>  
  31.   </Item>  
  32.   <NumberItems>1111</NumberItems>  
  33.   <Total>3704.00</Total>  
  34.   <OrderDate>07/07/2002</OrderDate>  
  35.   <OrderNumber>8876</OrderNumber>  
  36. </Order>  
<?xml version="1.0" ?> <Order> <Account>9900234</Account> <Item id="1"> <SKU>1234</SKU> <PricePer>5.95</PricePer> <Quantity>100</Quantity> <Subtotal>595.00</Subtotal> <Description>Super Widget Clamp</Description> </Item> <Item id="2"> <SKU>6234</SKU> <PricePer>22.00</PricePer> <Quantity>10</Quantity> <Subtotal>220.00</Subtotal> <Description>Mighty Foobar Flange</Description> </Item> <Item id="3"> <SKU>9982</SKU> <PricePer>2.50</PricePer> <Quantity>1000</Quantity> <Subtotal>2500.00</Subtotal> <Description>Deluxe Doohickie</Description> </Item> <Item id="4"> <SKU>3256</SKU> <PricePer>389.00</PricePer> <Quantity>1</Quantity> <Subtotal>389.00</Subtotal> <Description>Muckalucket Bucket</Description> </Item> <NumberItems>1111</NumberItems> <Total>3704.00</Total> <OrderDate>07/07/2002</OrderDate> <OrderNumber>8876</OrderNumber> </Order>

然后把Item结点的数据读出。

相关的JS函数如下:

Js代码
  1.   

下面是测试网页代码:

Html代码
  1. <body onload="getDataNext()">  
  2. <form>  
  3.   <table border="0">  
  4.     <tr>  
  5.         <td>SKU</td>  
  6.         <td><input type="text" name="SKU"></td>  
  7.     </tr>  
  8.     <tr>  
  9.        <td>Price</td>  
  10.        <td><input type="text" name="Price"></td>  
  11.     </tr>  
  12.     <tr>  
  13.         <td>Quantity</td>  
  14.         <td><input type="text" name="Quantity"></td>  
  15.     </tr>  
  16.     <tr>  
  17.         <td>Total</td>  
  18.         <td><input type="text" name="Total"></td>  
  19.     </tr>  
  20.     <tr>  
  21.         <td>Description</td>  
  22.         <td><input type="text" name="Description"></td>  
  23.      </tr>  
  24.   </table>  
  25.     <input type="button" value="<<" onClick="getDataPrev()">  
  26.      <input type="button" value=">>" onClick="getDataNext()">  
  27.   </form>  
  28. </body> 
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载