Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 417159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:33:10+00:00 2026-05-12T18:33:10+00:00

I have this XML that I am trying to read into an object hierarchy:

  • 0

I have this XML that I am trying to read into an object hierarchy:

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
  <Response>
    <name>1321 herbert street, Warren, MI</name>
    <Status>
      <code>200</code>
      <request>geocode</request>
    </Status>
    <Placemark id="p1">
      <address>Herbert St, Madison Heights, MI 48071, USA</address>
      <AddressDetails Accuracy="6" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
        <Country>
          <CountryNameCode>US</CountryNameCode>
          <CountryName>USA</CountryName>
        </Country>
      </AddressDetails>
    </Placemark>
    <Placemark id="p2">
      <address>Herbert Ave, Warren, MI 48089, USA</address>
      <AddressDetails Accuracy="6" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
        <Country>
          <CountryNameCode>US</CountryNameCode>
          <CountryName>USA</CountryName>
        </Country>
      </AddressDetails>
    </Placemark>
  </Response>
</kml>

Here are my objects:

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

        <XmlElementAttribute("Placemark")> Public Placemark As Placemark()

    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
        Private _AddressDetails As AddressDetails
        Private _ID As String

        <XmlAttributeAttribute("id")> Public Property ID() As String
            Get
                Return _ID
            End Get
            Set(ByVal value As String)
                _ID = value
            End Set
        End Property

        Public Property address() As String
            Get
                Return _address
            End Get
            Set(ByVal value As String)
                _address = value
            End Set
        End Property

        '<XmlAttributeAttribute("Accuracy")> _
        Public Property AddressDetails() As AddressDetails
            Get
                Return _AddressDetails
            End Get
            Set(ByVal value As AddressDetails)
                _AddressDetails = value
            End Set
        End Property

    End Class

    Public Class AddressDetails

        Private _Country As Country
        Public Property Country() As Country
            Get
                Return _Country
            End Get
            Set(ByVal value As Country)
                _Country = value
            End Set
        End Property

    End Class

    Public Class Country

        Private _CountryNameCode As String
        Public Property CountryNameCode() As String
            Get
                Return _CountryNameCode
            End Get
            Set(ByVal value As String)
                _CountryNameCode = value
            End Set
        End Property

        Private _CountryName As String
        Public Property CountryName() As String
            Get
                Return _CountryName
            End Get
            Set(ByVal value As String)
                _CountryName = value
            End Set
        End Property

    End Class
End Namespace

…and I am using this routine to deserialize the XML into my objects:

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

The problem is when I try parse the AddressDetails node. Something about the Attributes is screwing things up and I don’t know how to handle it. If I remove the attribute information on the AddressDetails nodes, the deserialization works fine, but I don’t have that option.

You may notice my commented out attempt to handle Accuracy attribute like was done for the earlier ID attribute on the Placemark node.

What do I have to do to get it to work with the attribute info on the AddressDetail nodes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:33:10+00:00Added an answer on May 12, 2026 at 6:33 pm

    Try this:

    <XmlElement(elementName:="AddressDetails", Namespace:="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0")> Public Property AddressDetails() As AddressDetails
        Get
            Return _AddressDetails
        End Get
        Set(ByVal value As AddressDetails)
            _AddressDetails = value
        End Set
    End Property
    
    
    
        <XmlAttributeAttribute("Accuracy")> Public Property Accuracy() As Integer
            Get
                Return _Accuracy
            End Get
            Set(ByVal value As Integer)
                _Accuracy = value
            End Set
        End Property
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some XML that I am trying to deserialize. The Kronos_WCF object deserializes
ok so I am trying to parse XML data into a table, this is
I have an xml file that looks like this: <!DOCTYPE ROOT SYSTEM zombie.dtd> <ROOT>
I have an XML file and I'm trying convert it into a (table( HTML
I'm trying to write an XML over HTTP push notification consumer that accepts the
I have many, (15-20) different XML files that I need to load to VB.Net.
I'm trying to write function similar to http://whatismyudid.com/ that, then approved, will return the
I have a given markup that I'm trying to apply to some style on.
I have been trying to work with Delphi 2010 and MSXML for the past
Hello I been trying to find this memory leak for a while now and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.