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 8594101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:07:39+00:00 2026-06-12T00:07:39+00:00

I have a following xml with duplicate nodes named(address) and I need to deserialize

  • 0

I have a following xml with duplicate nodes named(“address”) and I need to deserialize these “address” nodes to one object:

<dealer id="8569" ed="0">
  <name hide="0">some name</name>
  <url>http://www.some.com</url>
  <address hide="0" />
  <address>
    <line1>text1</line1>
    <line2>text2</line2>
    <line3>text3</line3>
    <town>Town</town>
    <postcode>Postcode</postcode>
  </address>
</dealer>

I need to deserialize it to the following class:

public class Dealer
{
    public Dealer()
    {
        _address = new Address();
    }

    [XmlAttribute("id")]
    public long Id { get; set; }

    [XmlElement("name")]
    public string Name{ get; set; }

    [XmlElement("url")]
    public string Url{ get; set; }

    [XmlElement("address")]
    public Address Address{ get; set; }

}    
public class Address
{
    [XmlElement("line1")]
    public string Line1{ get; set; }

    [XmlElement("line2")]
    public string Line2 { get; set; }

    [XmlElement("line3")]
    public string Line3 { get; set; }

    [XmlElement("county")]
    public string County{ get; set; }

    [XmlElement("town")]
    public string Town{ get; set; }

    [XmlElement("postcode")]
    public string Postcode{ get; set; }
}

When this xml is deserialized to above class, it always gets the first “address” node, however, I need the second node to be picked up. How can I do this?

  • 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-06-12T00:07:40+00:00Added an answer on June 12, 2026 at 12:07 am

    Short of changing your XML schema, all I can think of is having your Dealer class implement IXmlSerializable and implement the associated ReadXml method to use the desired xml node. http://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializable.readxml.aspx

    Other than that, you could alter your Dealer.Address to be a collection/array of Address objects which are compatible to both representations then after deserialization ignore/remove the empty address from the collection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a xml like following one. <testing> <node01 name=node01Name> <node02s> <node02 name=1> <CustomProperties>
I have the following xml: <product> <name>beef</name> <category>food</category> <unknownfield1>..</unknownfield1> <unknownfield2>..</unknownfield2> </product> I need to
Learning xml, Can anyone help me? I have following XML code: **<book lang=en>name of
I have the following XML structure: <node name=A> <node name=B> <node name=C/> <node name=D/>
I have following XML string: <persons> <person> <name>Someone</name> <age>27</age> </person> <person> <name>Otherone</name> <age>43</age> </person>
i have following XML <Queue> <UserName>UserName</UserName> <Type>1</Type> <Portal name=Portal1> <IndexesForSelect> <Index>Index1</Index> <Index>Index2</Index> </IndexesForSelect> </Portal>
I have following xml file: <doc_xml> <nodes> <node id='1' spec={spec_a=0.9, spec_b=0.1} /> <node id='2'
Possible Duplicate: PHP XML how to output nice format I have the following PHP
I have following xml and I want to fetch the value of node which
I have following XML, and i wish to save its data in my SQL

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.