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

  • SEARCH
  • Home
  • 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 4575034
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:00:23+00:00 2026-05-21T20:00:23+00:00

i have a xml file and i am trying to populate my list with

  • 0

i have a xml file and i am trying to populate my list with the data through deserialization.

my xml is here

<?xml version="1.0" ?>
<CustomerQueryRs>
    <CustomerRet>
        <ListID>6BE0000-1159990808</ListID>
        <Name>+ Blaine Bailey</Name>
        <FullName>+ Blaine Bailey</FullName>
        <Phone>866-855-0800</Phone>
    </CustomerRet>
    <CustomerRet>
        <ListID>9BA0000-1165353294</ListID>
        <Name>+ Brian Boyd</Name>
        <FullName>+ Brian Boyd</FullName>
        <Phone>203-245-1877</Phone>
    </CustomerRet>
        <CustomerRet>
        <ListID>9280000-1164147562</ListID>
        <Name>+ Brian Leahy</Name>
        <FullName>+ Brian Leahy</FullName>
        <Phone>508-341-0955</Phone>
    </CustomerRet>
</CustomerQueryRs>

here i am giving my full code. i just do not understand why my code is not working…what is missing in my code……it is not giving error but list is not getting populated. so please tell me which area i need to rectify in code.

[XmlTypeAttribute(AnonymousType = true)]
public class CustomersData
{
    [XmlArray(ElementName = "CustomerQueryRs")]
    [XmlArrayItem(ElementName = "CustomerRet")]
    public List<Customer> Customers { get; set; }

    public CustomersData()
    {
        Customers = new List<Customer>();
    }

}

public class Customer
{
    [XmlElement(ElementName = "ListID")]
    public string ListID { get; set; }

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

    [XmlElement(ElementName = "FullName")]
    public string FullName { get; set; }

    [XmlElement(ElementName = "Phone")]
    public string Phone { get; set; }
}

here is my desirialization code

private object DeserialzeXml(string xml)
    {
        var xmlSer = new XmlSerializer(typeof(CustomersData), new XmlRootAttribute("CustomerQueryRs"));
        var stringReader = new StringReader(xml);
        return xmlSer.Deserialize(stringReader);
    }

please help……

  • 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-21T20:00:23+00:00Added an answer on May 21, 2026 at 8:00 pm

    This should work:

    [XmlElement("CustomerRet")]
    public List<Customer> Customers { get; set; }
    

    And a full example:

    [XmlTypeAttribute(AnonymousType = true)]
    public class CustomersData
    {
        [XmlElement("CustomerRet")]
        public List<Customer> Customers { get; set; }
    
        public CustomersData()
        {
            Customers = new List<Customer>();
        }
    }
    
    public class Customer
    {
        [XmlElement(ElementName = "ListID")]
        public string ListID { get; set; }
    
        [XmlElement(ElementName = "Name")]
        public string Name { get; set; }
    
        [XmlElement(ElementName = "FullName")]
        public string FullName { get; set; }
    
        [XmlElement(ElementName = "Phone")]
        public string Phone { get; set; }
    }
    
    class Program
    {
        static void Main()
        {
            var xml = 
    @"<?xml version=""1.0"" ?>
    <CustomerQueryRs>
      <CustomerRet>
        <ListID>6BE0000-1159990808</ListID>
        <Name>+ Blaine Bailey</Name>
        <FullName>+ Blaine Bailey</FullName>
        <Phone>866-855-0800</Phone>
      </CustomerRet>
      <CustomerRet>
        <ListID>9BA0000-1165353294</ListID>
        <Name>+ Brian Boyd</Name>
        <FullName>+ Brian Boyd</FullName>
        <Phone>203-245-1877</Phone>
      </CustomerRet>
      <CustomerRet>
        <ListID>9280000-1164147562</ListID>
        <Name>+ Brian Leahy</Name>
        <FullName>+ Brian Leahy</FullName>
        <Phone>508-341-0955</Phone>
      </CustomerRet>
    </CustomerQueryRs>";
            var serializer = new XmlSerializer(typeof(CustomersData), new XmlRootAttribute("CustomerQueryRs"));
            using (var stringReader = new StringReader(xml))
            using (var reader = XmlReader.Create(stringReader))
            {
                var result = (CustomersData)serializer.Deserialize(reader);
                Console.WriteLine(result.Customers[1].FullName);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file that I'm trying to read from here , and
So I have an XML file that I am trying to loop through in
I have an xml file(from federal government's data.gov) which I'm trying to read with
I have an xml file and I am trying to get a list of
I have an XML file that I'm trying to serialize into an object. Some
I have an XML file that I'm trying to parse with Linq-to-XML. One of
I have an XML file as follows, and I'm trying to read the content
i have a simple xml file in a wcf service that i am trying
Have been trying to encrypt an xml file to a string so that I
I have a really simple XML file that I'm trying to read, but I

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.