title: Parsing XML Parsing through VB.NET
body: <p>So I wrote this program in VB.NET (well took code and modified it) and it grabs information from a POST. stores that information into a value. Now am trying to parse through that value and I cant get it through. Anyway anyone can provide some sample code I can follow?</p>
  
  <p><strong>Note:</strong> The XML is coming from a URL POST. Here's a snippet:</p>
  
  <pre><code>Imports System
  Imports System.IO
  Imports System.Net
  Imports System.Text
  Imports System.Xml
  
  Module Module1
      Public Class WebRequestPostExample
          Public Shared Sub Main()
              ' Create a request using a URL that can receive a post.
              Dim request As WebRequest = WebRequest.Create("https://quickvin.carfax.com/1 ")
              ' Set the Method property of the request to POST.
              request.Method = "POST"
              ' Create POST data and convert it to a byte array.
              Dim postData As String
  
              postData = "&lt;carfax-request&gt;"
              postData = postData &amp; "&lt;license-plate&gt;HSM2688&lt;/license-plate&gt;"
              postData = postData &amp; "&lt;state&gt;PA&lt;/state&gt;"
              postData = postData &amp; "&lt;vin&gt;&lt;/vin&gt;"
              postData = postData &amp; "&lt;product-data-id&gt;5A5AE0DA8BC016CF&lt;/product-data-id&gt;"
              postData = postData &amp; "&lt;location-id&gt;CARFAX&lt;/location-id&gt;"
              postData = postData &amp; "&lt;/carfax-request&gt;"
  
              Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
              ' Set the ContentType property of the WebRequest.
              request.ContentType = "application/x-www-form-urlencoded"
              ' Set the ContentLength property of the WebRequest.
              request.ContentLength = byteArray.Length
              ' Get the request stream.
              Dim dataStream As Stream = request.GetRequestStream()
              ' Write the data to the request stream.
              dataStream.Write(byteArray, 0, byteArray.Length)
              ' Close the Stream object.
              dataStream.Close()
              ' Get the response.
              Dim response As WebResponse = request.GetResponse()
              ' Display the status.
              Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
              ' Get the stream containing content returned by the server.
              dataStream = response.GetResponseStream()
              ' Open the stream using a StreamReader for easy access.
              Dim reader As New StreamReader(dataStream)
              ' Read the content.
              Dim responseFromServer As String = reader.ReadToEnd()
              ' Display the content.
              Console.WriteLine(responseFromServer)
  
  
              Try
                  Dim m_xmld As XmlDocument
                  Dim m_nodelist As XmlNodeList
                  Dim m_node As XmlNode
                  'Create the XML Document
                  m_xmld = New XmlDocument()
                  'Load the Xml file
                  XDocument.Load("https://quickvin.carfax.com/1") 'something keeps failing at this point
                  'Get the list of name nodes 
                  m_nodelist = m_xmld.SelectNodes("/request-info/")
                  'Loop through the nodes
                  For Each m_node In m_nodelist
                      'Get the Gender Attribute Value
                      Dim licenseplateAttribute = m_node.Attributes.GetNamedItem("license-plate").Value
                      'Get the firstName Element Value
                      Dim locationidValue = m_node.ChildNodes.Item(0).InnerText
                      'Get the lastName Element Value
                      Dim stateValue = m_node.ChildNodes.Item(1).InnerText
                      'Get the lastName Element Value
                      Dim vinValue = m_node.ChildNodes.Item(2).InnerText
                      'Write Result to the Console
                      Console.Write("Gender: " &amp; licenseplateAttribute _
                        &amp; " FirstName: " &amp; locationidValue &amp; " LastName: " _
                        &amp; stateValue)
                      Console.Write(vbCrLf)
                  Next
              Catch errorVariable As Exception
                  'Error trapping
                  Console.Write(errorVariable.ToString())
              End Try
              ' Clean up the streams.
              reader.Close()
              dataStream.Close()
              response.Close()
          End Sub
      End Class
  End Module
  </code></pre>