title: VB.NET XML parser loop
body: <p>Hey all i am new to XML parsing on VB.net. This is the code i am using to parse an XML file i have:</p>
  
  <pre><code>Dim output As StringBuilder = New StringBuilder()
  
  Dim xmlString As String = _
      "&lt;ip_list&gt;" &amp; _
          "&lt;ip&gt;" &amp; _
              "&lt;ip&gt;192.168.1.1&lt;/ip&gt;" &amp; _
              "&lt;ping&gt;9 ms&lt;/ping&gt;" &amp; _
              "&lt;hostname&gt;N/A&lt;/hostname&gt;" &amp; _
           "&lt;/ip&gt;" &amp; _
           "&lt;ip&gt;" &amp; _
               "&lt;ip&gt;192.168.1.6&lt;/ip&gt;" &amp; _
               "&lt;ping&gt;0 ms&lt;/ping&gt;" &amp; _
               "&lt;hostname&gt;N/A&lt;/hostname&gt;" &amp; _
           "&lt;/ip&gt;" &amp; _
     "&lt;/ip_list&gt;"
  
  Using reader As XmlReader = XmlReader.Create(New StringReader(xmlString))
          'reader.ReadStartElement("ip_list")
  
          Do Until reader.EOF
              reader.ReadStartElement("ip_list")
              reader.ReadStartElement("ip")
              reader.ReadStartElement("ip")
              reader.MoveToFirstAttribute()
  
              Dim theIP As String = reader.Value.ToString
              reader.ReadToFollowing("ping")
              Dim thePing As String = reader.ReadElementContentAsString().ToString
              reader.ReadToFollowing("hostname")
              Dim theHN As String = reader.ReadElementContentAsString().ToString
  
              MsgBox(theIP &amp; " " &amp; thePing &amp; " " &amp; theHN)
              reader.ReadEndElement()
          Loop
  
          reader.Close()
      End Using
  </code></pre>
  
  <p>I put the <code>do until reader.EOF</code> myself but it does not seem to work. It keeps giving an error after the first go around. I must be missing something?</p>
  
  <p>David</p>