Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET General (http://www.xtremevbtalk.com/-net-general/)
-   -   Problem with Reading XML (http://www.xtremevbtalk.com/-net-general/328606-reading-xml.html)

digitaldrew 03-24-2017 03:58 PM

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="http://schemas.xmlsoap.org/soap/envelope/">
      <ns7:SgndCommandResponse xmlns:ns7="http://www.nic.es/sgnd/schemas" xmlns:ns10="http://www.nic.es/sgnd/schemas-movement" xmlns:ns11="http://www.nic.es/sgnd/schemas-invoice" xmlns:ns12="http://www.nic.es/sgnd/schemas-tradeaction" xmlns:ns13="http://www.nic.es/sgnd/schemas-ownershipcertificate" xmlns:ns14="http://www.nic.es/sgnd/schemas-statistic" xmlns:ns2="http://www.nic.es/sgnd/schemas-domain" xmlns:ns3="http://www.nic.es/sgnd/schemas-order" xmlns:ns4="http://www.nic.es/sgnd/schemas-contact" xmlns:ns5="http://www.nic.es/sgnd/schemas-host" xmlns:ns6="http://www.nic.es/sgnd/schemas-dnssec" xmlns:ns8="http://www.nic.es/sgnd/schemas-inbox" xmlns:ns9="http://www.nic.es/sgnd/schemas-extraordinarycancelation">
              <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 (domainavailable1.es) and (domainavailable2.es) 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 (notavailable.es) 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!

All times are GMT -6. The time now is 09:43 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.