Problem with Reading XML
Problem with Reading XML
Problem with Reading XML
Problem with Reading XML
Problem with Reading XML
Problem with Reading XML Problem with Reading XML Problem with Reading XML Problem with Reading XML Problem with Reading XML Problem with Reading XML Problem with Reading XML Problem with Reading XML
Problem with Reading XML Problem with Reading XML
Problem with Reading XML
Go Back  Xtreme Visual Basic Talk > > > Problem with Reading XML


Reply
 
Thread Tools Display Modes
  #1  
Old 03-24-2017, 03:58 PM
digitaldrew digitaldrew is offline
Newcomer
 
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.

Code:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <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">
         <ns7:DomainCreateResponse>
            <ns2:Name>domainavailable1.es</ns2:Name>
            <ns2:Name>domainavailable2.es</ns2:Name>
            <ns2:Autorenew>false</ns2:Autorenew>
            <ns2:Creation>2016-11-24T15:07:05.364+01:00</ns2:Creation>
            <ns2:Expiration>2017-11-24T15:07:05.364+01:00</ns2:Expiration>
            <ns2:Order>
               <ns3:OrderId>553905</ns3:OrderId>
               <ns3:OrderType>1</ns3:OrderType>
               <ns3:State>DMOK</ns3:State>
               <ns3:StateDescription>Efectuada</ns3:StateDescription>
               <ns3:Creation>2016-11-24T15:07:05.398+01:00</ns3:Creation>
               <ns3:Reference>AD-ES-553905-F5</ns3:Reference>
               <ns3:DomainData>
                  <ns2:Name>domainavailable1.es</ns2:Name>
               </ns3:DomainData>
            </ns2:Order>
            <ns2:Order>
               <ns3:OrderId>553906</ns3:OrderId>
               <ns3:OrderType>1</ns3:OrderType>
               <ns3:State>DMOK</ns3:State>
               <ns3:StateDescription>Efectuada</ns3:StateDescription>
               <ns3:Creation>2016-11-24T15:07:05.603+01:00</ns3:Creation>
               <ns3:Reference>AD-ES-553906-F5</ns3:Reference>
               <ns3:DomainData>
                  <ns2:Name>domainavailable2.es</ns2:Name>
               </ns3:DomainData>
            </ns2:Order>
            <ns2:NotIncluded>
               <ns2:ErrorCause id="3019">
                  <ns2:Name>notavailable.es</ns2:Name>
               </ns2:ErrorCause>
               <ns2:ErrorCause id="3001">
                  <ns2:Name>domain.incorrect</ns2:Name>
               </ns2:ErrorCause>
            </ns2:NotIncluded>
         </ns7:DomainCreateResponse>
         <ns7:ReturnCode>1000</ns7:ReturnCode>
         <ns7:ServerData>
            <ns7:Timestamp>2016-11-24T15:07:05.767+01:00</ns7:Timestamp>
            <ns7:ClientID>CLIENT-ID-AR-CHECKLIST</ns7:ClientID>
            <ns7:ServerID>1479996425767</ns7:ServerID>
         </ns7:ServerData>
      </ns7:SgndCommandResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
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?

Code:
                        'READ RESPONSE WITH MULTIPLE DOMAINS
                        Dim doc As New XmlDocument()
                        doc.Load(WebResponse)
                        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)
                            removeDomain(nodeDomain)
                        Next

                        '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)
                            Else
                                txtLog.AppendText(nodeDomain2 & " UNKNOWN ERROR (ID: " & sResult & ") ...via ESNIC THREAD(1) at: " & TimeOfDay & vbCrLf)
                            End If
                        Next
Thanks in advance!
Reply With Quote
Reply

Tags
dim, domain, domains, vbcrlf, thread1, esnic, domainavailable1.es, timeofday, domainavailable2.es, string, handle, sresult, xml, notavailable.es, tags, dmok, nodelist, pull, read, proper, efectuada, nodedomain, string.empty, nodedomain2, check


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Problem with Reading XML
Problem with Reading XML
Problem with Reading XML Problem with Reading XML
Problem with Reading XML
Problem with Reading XML
Problem with Reading XML Problem with Reading XML Problem with Reading XML Problem with Reading XML Problem with Reading XML Problem with Reading XML Problem with Reading XML
Problem with Reading XML
Problem with Reading XML
 
Problem with Reading XML
Problem with Reading XML
 
-->