Parsing XML Response in VBA and extracting only last data

前端 未结 2 2025
时光取名叫无心
时光取名叫无心 2021-01-27 20:48

I\'m trying to do a XML request through excel vba for one of the internal links (in our company). when i send request and receive response using the code below, i get the follow

2条回答
  •  半阙折子戏
    2021-01-27 21:44

    Considering the fact, that you have already parsed the XML to string, then the easiest fact is to try to slice the string. To see how it works, put the string from .responseText to A1 range and run this:

    Sub TestMe()
    
        Dim responseText As String
        responseText = Range("A1")
    
        Dim myArr As Variant
        myArr = Split(responseText, "Demand"":""")
        Debug.Print Left(myArr(UBound(myArr)), Len(myArr(UBound(myArr))) - 4)
    
    End Sub
    

    What it does is to split the string into array by the word Demand":" and to take anything but the last 4 characters of the last unit of the array.

提交回复
热议问题