高手帮忙解析下这个XML文档
<DBSET><ROW>
<COL NAME="APP_NO">FC00045752</COL>
<COL NAME="TESTER_NO">DSZF930G</COL>
<COL NAME="CONS_NO">北京电力</COL>
<COL NAME="TEST_ATTR_CODE">114</COL>
<COL NAME="METER_ID">411054</COL>
<COL NAME="CONS_NAME">112</COL>
<COL NAME="ELEC_ADDR">112</COL>
<COL NAME="SUBS_NAME">3201</COL>
<COL NAME="LINE_NAME">220</COL>
<COL NAME="BAR_CODE">5</COL>
<COL NAME="ASSET_NO">114</COL>
<COL NAME="MADE_NO">111</COL>
</ROW>
<ROW>
<COL NAME="APP_NO">FC00045753</COL>
<COL NAME="TESTER_NO">DSZF930G</COL>
<COL NAME="CONS_NO">上海电力</COL>
<COL NAME="TEST_ATTR_CODE">114</COL>
<COL NAME="METER_ID">411054</COL>
<COL NAME="CONS_NAME">113</COL>
<COL NAME="ELEC_ADDR">113</COL>
<COL NAME="SUBS_NAME">3201</COL>
<COL NAME="LINE_NAME">221</COL>
<COL NAME="BAR_CODE">6</COL>
<COL NAME="ASSET_NO">115</COL>
<COL NAME="MADE_NO">112</COL>
</ROW>
<ROW>
<COL NAME="APP_NO">FC00045753</COL>
<COL NAME="TESTER_NO">DSZF930G</COL>
<COL NAME="CONS_NO">浙江电力</COL>
<COL NAME="TEST_ATTR_CODE">114</COL>
<COL NAME="METER_ID">411054</COL>
<COL NAME="CONS_NAME">113</COL>
<COL NAME="ELEC_ADDR">113</COL>
<COL NAME="SUBS_NAME">3201</COL>
<COL NAME="LINE_NAME">221</COL>
<COL NAME="BAR_CODE">6</COL>
<COL NAME="ASSET_NO">115</COL>
<COL NAME="MADE_NO">112</COL>
</ROW>
</DBSET>
最好用VB解析下,小弟感激不尽! --------------------编程问答-------------------- 引用 Microsoft XML, version 2.0 或更高版本
Option Explicit
Sub Main()
Dim xmlDoc As DOMDocument
Dim xmlRows As IXMLDOMNodeList
Dim xmlRow As IXMLDOMElement
Dim xmlCol As IXMLDOMElement
Set xmlDoc = New DOMDocument
xmlDoc.Load "C:\temp\1.xml"
Set xmlRows = xmlDoc.selectNodes("//ROW")
For Each xmlRow In xmlRows
For Each xmlCol In xmlRow.childNodes
Debug.Print xmlCol.getAttribute("NAME") & " = " & xmlCol.Text
Next
Debug.Print "----"
Next
End Sub
注意 xml 文件应该有下面这行开头,否则有中文就无法解析
<?xml version="1.0" encoding="GB2312"?>--------------------编程问答-------------------- 现时建议引用xml6. --------------------编程问答--------------------
2.0以上都可以的
补充:VB , 网络编程