Trebor8484
Board Regular
- Joined
- Oct 27, 2018
- Messages
- 69
- Office Version
- 2013
- Platform
- Windows
Hi,
Does anyone know how I can ammend the below code to wait for the web page to finish loading please?
Also, I am trying to obtain the book id, but not sure how to accomplish this.
Thanks
Does anyone know how I can ammend the below code to wait for the web page to finish loading please?
Also, I am trying to obtain the book id, but not sure how to accomplish this.
Rich (BB code):
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
VBA Code:
Sub xmlParse()
Dim oXMLHTTP As Object
Dim sPageHTML As String
Dim sURL As String
Dim XmlMapResponse As String
Dim strXML As String
Dim XDoc As MSXML2.DOMDocument60
Dim xNode As MSXML2.IXMLDOMNode
sURL = "https://gist.githubusercontent.com/Ram-N/5189462/raw/46db0b43ad7bf9cbd32a8932f3ab981bd4b4da7c/books.xml"
Set oXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
oXMLHTTP.Open "GET", sURL, False
oXMLHTTP.send
XmlMapResponse = oXMLHTTP.responseText
strXML = XmlMapResponse
Set XDoc = New MSXML2.DOMDocument60
If Not XDoc.LoadXML(strXML) Then
Err.Raise XDoc.parseError.ErrorCode, , XDoc.parseError.reason
End If
' Selects the author element for the first book element
Set xNode = XDoc.SelectSingleNode("catalog/book[1]/author")
Debug.Print xNode.Text & vbNewLine
' Loop through each title element that is the child of the book element
For Each xNode In XDoc.SelectNodes("catalog/book/title")
Debug.Print xNode.Text
Next xNode
End Sub
Thanks