Search code examples
vb.netxmlelement

VB.NET and XmlElement() How do I get the value of the elements out of an API call?


I have a successful API call and return of data in an XmlElement however I am not able to find out how to parse out the data I need.

Dim Any = CardInqResponse.CardInqRec.Custom.Any <-- This is my xmlelement.

My return shows Length of two (two Elements).
My element names are Exp and Offset. I am interested in the data in Offset where I can see these values returned in innerText and innerXml.

How do I get the value of either of these two to store in a string?


Solution

  •        Dim offset As String           
           Dim Any =  CardInqResponse.CardInqRec.Custom.Any
    
           For Each node As XmlElement In Any
               If node.Name = "Offset" Then
                Try
                    offset = node.InnerText.ToString
                Catch
                End Try
              End If              
            Next