读取XML属性VBA [英] Read XML Attribute VBA
本文介绍了读取XML属性VBA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试获取VBA中单个节点的属性,但无法使用DOM进行管理
I am trying to get the attribute of a single node in VBA, but can't manage it using DOM
XML如下所示:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetUserInfoResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/">
<GetUserInfoResult>
<GetUserInfo>
<User ID="16" Name="" LoginName="login" Email="" Notes="" IsSiteAdmin="False" IsDomainGroup="False" />
</GetUserInfo>
</GetUserInfoResult>
</GetUserInfoResponse>
</soap:Body>
</soap:Envelope>
我基本上只是试图获取ID属性的值。任何帮助将不胜感激。
I am basically just trying to get the value of the ID attribute. Any help would be appreciated.
推荐答案
尝试:
引用Microsoft XML v3,我将xml保存到桌面上的文件中)
(Include a reference to Microsoft XML v3, I saved your xml to a file on my desktop)
Dim xmlDoc As DOMDocument30
Set xmlDoc = New DOMDocument30
xmlDoc.Load ("C:\users\jon\desktop\test.xml")
Dim id As String
id = xmlDoc.SelectSingleNode("//GetUserInfo/User").Attributes.getNamedItem("ID").Text
这篇关于读取XML属性VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文