读取 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:usersjondesktop est.xml")
Dim id As String
id = xmlDoc.SelectSingleNode("//GetUserInfo/User").Attributes.getNamedItem("ID").Text
这篇关于读取 XML 属性 VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文