VB读取XML节点属性值
				
									
					
					
						|  | 
							admin 2012年7月9日 1:33
								本文热度 5035 | 
					
				 
				

XML文件内容如下:
<?xml version="1.0" encoding="gb2312" ?> 
- <root> 
- <order name="订单数据" 测试使用="ceshisdfd"> 
  <row 订单编号="62" 下单时间="2008-10-3 上午 12:28:30" 产品名称="金维" 产品价格="169" 当前状态="3" 广告编号="45" />   <row 订单编号="65" 下单时间="2008-10-4 上午 13:28:30" 产品名称="系列" 产品价格="166" 当前状态="5" 广告编号="41" />   <row 订单编号="63" 下单时间="2009-11-4 上午 11:08:57" 产品名称="系列" 产品价格="133" 当前状态="1" 广告编号="39" /> 
  </order> 
  </root> 
 
问题补充: 
如上图所示有个xml文件,现在我想读取订单数据节点下的所有数据,如订单编号为62、65、63甚至更多的数据,请问路过的各位高手如何使用VB来实现?
 
满意答案
Private Sub Command1_Click()
Dim Dom As New DOMDocument
Dom.async = False
Dom.Load "a.xml"
Dim node As IXMLDOMNode
Set node = Dom.selectSingleNode("root").selectSingleNode("order")
Dim x As IXMLDOMNode
For Each x In node.childNodes
    MsgBox x.Attributes.getNamedItem("订单编号").Text
    MsgBox x.Attributes.getNamedItem("下单时间").Text
Next
Set Dom = Nothing
End Sub

 

   
该文章在 2012/7/9 1:33:03 编辑过