title: Parsing Google Earth XML data using VB.NET
body: <p>Here is a simplified version of the XML returned.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; 
      &lt;kml xmlns="http://earth.google.com/kml/2.0"&gt;
          &lt;Response&gt;
              &lt;name&gt;1321 herbert street, Warren, MI&lt;/name&gt; 
              &lt;Status&gt;
                  &lt;code&gt;200&lt;/code&gt; 
                  &lt;request&gt;geocode&lt;/request&gt; 
              &lt;/Status&gt;
              &lt;Placemark id="p1"&gt;
                  &lt;address&gt;Herbert St, Madison Heights, MI 48071, USA&lt;/address&gt; 
              &lt;/Placemark&gt;        
              &lt;Placemark id="p2"&gt;
                  &lt;address&gt;Add2&lt;/address&gt; 
              &lt;/Placemark&gt;
          &lt;/Response&gt;
      &lt;/kml&gt;  
  </code></pre>
  
  <p>In a <a href="https://stackoverflow.com/questions/1490663/whats-the-easiest-way-in-vb-net-to-parse-this-xml-into-objects">previous</a> post, I receieved help on how to parse this data into objects. Now. I need a tad bit more help in trying to read in teh repeating PLACEMARK nodes.</p>
  
  <p>This is the object structure I am trying to read into:</p>
  
  <pre><code>Namespace GoogleAddress
  
      Public Class kml
  
          Private _Response As Response
  
          Public Property Response() As Response
              Get
                  Return _Response
              End Get
              Set(ByVal value As Response)
                  _Response = value
              End Set
          End Property
  
      End Class
  
      Public Class Response
  
          Private _name As String
          Public Property name() As String
              Get
                  Return _name
              End Get
              Set(ByVal value As String)
                  _name = value
              End Set
          End Property
  
          Private _Status As Status
          Public Property Status() As Status
              Get
                  Return _Status
              End Get
              Set(ByVal value As Status)
                  _Status = value
              End Set
          End Property
  
          Private _Placemark() As Placemark
          '
          Public Property Placemark() As Placemark()
              Get
                  Return _Placemark
              End Get
              Set(ByVal value As Placemark())
                  _Placemark = value
              End Set
          End Property
  
      End Class
  
  
      Public Class Status
  
          Private _Code As Integer
          Public Property Code() As Integer
              Get
                  Return _Code
              End Get
              Set(ByVal value As Integer)
                  _Code = value
              End Set
          End Property
  
          Private _Request As String
          Public Property Request() As String
              Get
                  Return _Request
              End Get
              Set(ByVal value As String)
                  _Request = value
              End Set
          End Property
  
      End Class
  
      Public Class Placemark
  
          Private _Address As String
          Public Property Address() As String
              Get
                  Return _Address
              End Get
              Set(ByVal value As String)
                  _Address = value
              End Set
          End Property
  
      End Class
  
  End Namespace
  </code></pre>
  
  <p>I use the following routine to deserialize the XML shown above and populate the object above:</p>
  
  <pre><code>   Public Shared Function DeSerializeFromXMLString(ByVal TypeToDeserialize As System.Type, _
                                                      ByVal xmlString As String) As Object
  
          Dim bytes() As Byte = System.Text.Encoding.UTF8.GetBytes(xmlString)
          Dim mem As MemoryStream = New MemoryStream(bytes)
          Dim ser As System.Xml.Serialization.XmlSerializer = New System.Xml.Serialization.XmlSerializer(GetType(GoogleAddress.kml), "http://earth.google.com/kml/2.0")
          Dim KmlResult As GoogleAddress.kml = TryCast(ser.Deserialize(mem), GoogleAddress.kml) '
  
          Return KmlResult
  
      End Function
  </code></pre>
  
  <p>...But theobjects are not being properly populated and I do not get any Placemark objects (0 len array).</p>
  
  <p>Any suggstions?</p>