I am fairly new to reading an XML response using VBA (pardon my ignorance). There are several posts out there that explain it but I couldn't get it to replicate on my response. I am trying to get the title "H1" and the requiredID "22". Any ideas where am I going wrong?
Below is the xml response:
<?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>
<GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<GetListItemsResult>
<listitems 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">
<rs:data ItemCount="1">
<z:row Title="H1"
RequiredID="22"/>
</rs:data>
</listitems>
</GetListItemsResult>
</GetListItemsResponse>
</soap:Body>
</soap:Envelope>
And below is the VBA script:
Sub GetXML_Values()
Dim listNode As MSXML2.IXMLDOMNode
Dim XMLDOC As MSXML2.DOMDocument
Set XMLDOC = New MSXML2.DOMDocument
XMLDOC.async = False
XMLDOC.Load ("File Location")
XMLDOC.setProperty "SelectionLanguage", "XPath"
XMLDOC.setProperty "SelectionNamespaces", "xmlns:sp=""http://schemas.microsoft.com/sharepoint/soap/"""
Set lists = XMLDOC.SelectNodes("//soap:Envelope/soap:Body/sp:GetListItemsResponse/sp:GetListItemsResult/sp:listitems/sp:data")
txt = XMLDOC.SelectSingleNode("//data/row").Attributes.getNamedItem("Title").Text
txt = XMLDOC.getElementsByTagName("soap:Envelope")(0).Text
For Each listNode In lists
Text = listNode.ChildNodes(0).Text
Next
Set XMLDOC = Nothing
End Sub
Text = listNode.ChildNodes(0).getAttribute("Title").