PDA

View Full Version : Need to help to read a XML file



usubrama
04-03-2020, 04:43 AM
Hi ,

I have attached a file with this post . It is a XMl file

At the end of the file the folliwing snippet will be seen
<ns1:Value><ns1:GroupId>165582</ns1:GroupId><ns1:Status>SUCCESS</ns1:Status></ns1:Value></ns2:result>

I need to use vb script to get the value of group id.
I have used the syntax below.
oDoc.load(sReturnXml)
oNode = oDoc.getElementsByTagName("ns1:GroupId")
sGroupId = oNode.Text

But I cannot get the groupid value. Please help. Thank you

gmayor
04-03-2020, 09:23 PM
If you open the document in Word it will translate the xml and you could use VBA to get the value that you want e.g.

Sub Macro1()
Dim oRng As Range
Dim lngPara As Long
For lngPara = ActiveDocument.Paragraphs.Count To 1 Step -1
Set oRng = ActiveDocument.Paragraphs(lngPara).Range
oRng.End = oRng.End - 1
If IsNumeric(Trim(oRng.Text)) = True Then
MsgBox oRng.Text
Exit For
End If
Next lngPara
Set oRng = Nothing
End Sub