我有一个解决方案启动并运行。感谢@Blackhawk 为我指明了正确的方向。它将 xml 加载到 de MSXML DOM 中,并基于 GetElementsByTagName 遍历 NodeList。然后它使用几个字符串函数和循环将我想要的信息提取到数组中。
我对它所做的工作感到满意,但请随时指出可以做得更好的地方!
Sub IterateThroughNodelistXML()
Application.ScreenUpdating = False
Dim MyArray(1 To "some upper bound", 1 To 3)
Dim xmldoc As MSXML2.DOMDocument
Dim xmlNodeList As MSXML2.IXMLDOMNodeList
Dim xmlNode As MSXML2.IXMLDOMNode
Dim web_addresses, XML_Output As Worksheet
Dim str, strHttp, strValue_1, strValue_2 As String
Dim intPosition_1, intPosition_2 As Integer
Dim l, s As Integer
Dim i, bAscii As Byte
Dim c As Long
Dim dDate As Date
Set XML_Output = Sheets(1)
Set web_addresses = Sheets(2)
Set xmldoc = New MSXML2.DOMDocument
xmldoc.async = False
For l = 1 To web_addresses.Range("a1").CurrentRegion.Rows.Count
strHttp = web_addresses.Cells(l, 1).value
xmldoc.Load ("http://www.some_web_page" & strHttp)
Set xmlNodeList = xmldoc.getElementsByTagName("something")
For s = 1 To xmlNodeList.Length
str = xmlNodeList.Item(s).nodeTypedValue
intPosition_1 = InStrRev(str, "some search string", -1, vbBinaryCompare) - "some constant"
strValue_1 = Mid(str, intPosition_1, "some constant")
i = 9
bAscii = 0
While bAscii < 48 Or bAscii > 57
intPosition_2 = InStr(1, str, "some other search string", vbBinaryCompare) - i
strValue_2 = Mid(str, intPosition_2, i)
bAscii = AscW(strValue_2)
i = i - 1
Wend
c = c + 1
dDate = Date
MyArray(c, 1) = strValue_1
MyArray(c, 2) = strValue_2
MyArray(c, 3) = dDate
Next s
Next l
XML_Output.Range("a4").Resize(UBound(MyArray, 1), UBound(MyArray, 2)).value = MyArray
Application.ScreenUpdating = True
End Sub