vb读取XML某个节点内容

zj8092 2008-08-25 08:34:13
XML文档:
<?xml version="1.0" encoding="GB2312" ?>
<root>
<design>
<r>5</r>
<shape>circle</shape>
</design>
<design>
<r>10</r>
<shape>triangle</shape>
</design>
</root>

if r=10 then
显示内容
<r>10</r>
<shape>triangle</shape>
...全文
74 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zj8092 2008-08-26
  • 打赏
  • 举报
回复
<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
- <s:Schema id="RowsetSchema">

</s:Schema>
- <rs:data>
<z:row id="86" brdflag="1" cvouchtype="08" cbustype="其他入库" cwhcode="002" cwhname="公建库" ddate="2008-08-25T00:00:00" ccode="0000000027" crdcode="1" crdname="领料入库" cmaker="demo" vt_id="67" bisstqc="False" csource="库存" bpufirst="False" biafirst="False" bislsquery="False" iswfcontrolled="0" />
</rs:data>
</xml>


怎么把 <z:row id="86" brdflag="1" cvouchtype="08" cbustype="其他入库" cwhcode="002" cwhname="公建库" ddate="2008-08-25T00:00:00" ccode="0000000027" crdcode="1" crdname="领料入库" cmaker="demo" vt_id="67" bisstqc="False" csource="库存" bpufirst="False" biafirst="False" bislsquery="False" iswfcontrolled="0" />
</rs:data>读出来
zj8092 2008-08-26
  • 打赏
  • 举报
回复
A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<s:Schema id="RowsetSchema">
<s:ElementType name="row" content="eltOnly" rs:updatable="true">
</s:ElementType>
</s:Schema>
<rs:data>
<z:row id="86" brdflag="1" cvouchtype="08" cbustype="其他入库" cwhcode="002" cwhname="公建库" ddate="2008-08-25T00:00:00" ccode="0000000027" crdcode="1" crdname="领料入库" cmaker="demo" vt_id="67" bisstqc="False" csource="库存" bpufirst="False" biafirst="False" bislsquery="False" iswfcontrolled="0" />
</rs:data>
</xml>

怎么把 <z:row id="86" brdflag="1" cvouchtype="08" cbustype="其他入库" cwhcode="002" cwhname="公建库" ddate="2008-08-25T00:00:00" ccode="0000000027" crdcode="1" crdname="领料入库" cmaker="demo" vt_id="67" bisstqc="False" csource="库存" bpufirst="False" biafirst="False" bislsquery="False" iswfcontrolled="0" />
</rs:data>读出来
Edistein 2008-08-26
  • 打赏
  • 举报
回复
工程需要引用Microsoft XML x.0
Edistein 2008-08-26
  • 打赏
  • 举报
回复

Private Function getXML() As String
Dim xml As New DOMDocument
xml.loadXML "<?xml version=""1.0"" encoding=""GB2312"" ?>" & _
"<root>" & _
"<design>" & _
"<r>5 </r>" & _
"<shape>circle </shape>" & _
"</design>" & _
"<design>" & _
"<r>10 </r>" & _
"<shape>triangle </shape>" & _
"</design>" & _
"</root>"
Dim designNodes As IXMLDOMNodeList
Set designNodes = xml.selectNodes("/root/design")

Dim aNode As IXMLDOMNode
For Each aNode In designNodes
If aNode.selectSingleNode("r").Text = "10" Then
MsgBox aNode.xml '这里的aNode就是你想要的结点
Exit Function
End If
Next
End Function
zj8092 2008-08-26
  • 打赏
  • 举报
回复
有人知道吗

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧