I needed to modify a VB.NET 2.0 windows forms application to import data from an 2+GB XML file that is provided by a 3rd party.  The XML file contains multiple high level nodes, however I’m only concerned with nodes that match my “PARENTNODENAME”.  This file contains tens of thousands of “PARENTNODENAME” nodes that I need to parse and the perform various database actions with that data.

The VB.NET Code:

Dim bFirstRead As Boolean = True
Using r As XmlReader = XmlReader.Create(XMLFILENAME)
   While r.Read()
      If (bFirstRead) Then ' Only ReadToDescendant to get down to the "PARENTNODENAME" nodes initially
         bFirstRead = False
      End If

      If r.Name = "PARENTNODENAME" Then
         ' Parse nodes and import into database
      End If
   End While
End Using