View Single Post
Old 03-24-2017, 03:58 PM
digitaldrew digitaldrew is offline
Join Date: Nov 2012
Posts: 16
Default Problem with Reading XML

Hey everyone. I hope I can get some help here since I'm not really sure if I am doing this the right way.

I am sending a request that includes 4 domains which I would like to check the availability of. The response I receive (below) contains each domain with different responses that may be received. I am trying to figure out the best way to go through the XML and properly check for which ones come back as Available and which ones come back as Not Available.

<SOAP-ENV:Envelope xmlns:SOAP-ENV="">
      <ns7:SgndCommandResponse xmlns:ns7="" xmlns:ns10="" xmlns:ns11="" xmlns:ns12="" xmlns:ns13="" xmlns:ns14="" xmlns:ns2="" xmlns:ns3="" xmlns:ns4="" xmlns:ns5="" xmlns:ns6="" xmlns:ns8="" xmlns:ns9="">
               <ns2:ErrorCause id="3019">
               <ns2:ErrorCause id="3001">
The way I am currently trying to handle this is by looking for "ns2:Order" tags and then pulling the domain from each of those. As you can see above ( and ( are the two available domains here.

Next, I try to loop through and look for "ns2:NotIncluded" tags and pull the domain from there if it has an ErrorCause id of "3019".. As you can see above ( is the not available domain here.

Below is the complete code I am using to try and read through the XML above and pull the proper domain with the proper status (available) or (not available), but it does not seam to be working properly. Is there a better way I could be doing this?

                        Dim doc As New XmlDocument()
                        txtLog.AppendText(WebResponse & vbCrLf)

                        'HANDLE AVAILABLE DOMAINS
                        Dim nodelist As XmlNodeList = doc.GetElementsByTagName("ns2:Order")
                        For Each node As XmlElement In nodelist
                            Dim nodeDomain As String = String.Empty
                            nodeDomain = node("ns2:Name").InnerText
                            txtLog.AppendText(nodeDomain & " SUCCESS ...via ESNIC THREAD(1) at: " & TimeOfDay & vbCrLf)

                        'HANDLE NOT AVAILABLE DOMAINS
                        Dim nodelist2 As Xml.XmlNodeList = doc.GetElementsByTagName("ns2:NotIncluded")
                        For Each cat As Xml.XmlElement In nodelist2
                            Dim nodeDomain2 As String = String.Empty
                            Dim sResult As String = cat.GetAttribute("id")
                            nodeDomain2 = cat("ns2:Name").Value
                            If sResult = "3019" Then
                                txtLog.AppendText(nodeDomain2 & " NOT AVAILABLE ...via ESNIC THREAD(1) at: " & TimeOfDay & vbCrLf)
                                txtLog.AppendText(nodeDomain2 & " UNKNOWN ERROR (ID: " & sResult & ") ...via ESNIC THREAD(1) at: " & TimeOfDay & vbCrLf)
                            End If
Thanks in advance!
Reply With Quote