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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:52:57+00:00 2026-06-08T03:52:57+00:00

I get an XML type data, such as this; <Response> <Clients> <Client> <ID>1</ID> <Name>John</Name>

  • 0

I get an XML type data, such as this;

<Response>
  <Clients>
    <Client>
      <ID>1</ID>
      <Name>John</Name>
      <Age>25</Age>
      <Address>Some address</Address>
    </Client>
    <Client>
      <ID>2</ID>
      <Name>Mark</Name>
      <Age>22</Age>
      <Address>Some address2</Address>
    </Client>
    <Client>
      <ID>3</ID>
      <Name>Phil</Name>
      <Age>30</Age>
      <Address>Some address3</Address>
    </Client>
  </Clients>
</Response>

In C# I have the following code:

[XmlRoot("Response")]
public class MyClients
{
    [XmlElement("Clients", typeof(MyClient))]
    public List<MyClient> Clients { get; set; }
}

public class MyClient
{
    [XmlElement("ID")]
    public int ID;

    [XmlElement("Name")]
    public string Name;

    [XmlElement("Age")]
    public int Age;

    [XmlElement("Address")]
    public string Address;
}

and I try to get this data, using

public ActionResult GetClients()
{
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("someUrl");
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    XmlSerializer serializer = new XmlSerializer(typeof(WFMClientsList));
    Stream receiveStream = response.GetResponseStream();
    WFMClientsList clients = (MyClients)serializer.Deserialize(receiveStream);
}

but I get nothing in response.

Can anyone explain how to deserialize XML to List<MyClient> correctly?

  • 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-08T03:53:00+00:00Added an answer on June 8, 2026 at 3:53 am

    The problem is that what you have declared doesn’t actually match your XML. If you serialize an object from your current declaration, you get:

    <?xml version="1.0" encoding="utf-16"?>
    <Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <Clients>
        <ID>1</ID>
        <Name>John</Name>
        <Age>25</Age>
        <Address>Some address</Address>
      </Clients>
    </Response>
    

    Try:

    [XmlRoot("Response")]
    public class MyClients
    {
        [XmlArray("Clients")]
        [XmlArrayItem("Client")]
        public List<MyClient> Clients { get; set; }
    }
    
    [XmlRoot("Client")]
    public class MyClient
    {
        [XmlElement("ID")]
        public int ID;
        [XmlElement("Name")]
        public string Name;
        [XmlElement("Age")]
        public int Age;
        [XmlElement("Address")]
        public string Address;
    }
    

    Which produces:

    <?xml version="1.0" encoding="utf-16"?>
    <Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <Clients>
        <Client>
          <ID>1</ID>
          <Name>John</Name>
          <Age>25</Age>
          <Address>Some address</Address>
        </Client>
      </Clients>
    </Response>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can some one guide me how to parse this Xml type string ? <data>
I'm working with XML data from an application where we get XML like this:
this is xml let say: <.Sections> <.SECTION ID =4 NAME=GetStudents CONTROL-TYPE=Button LINK=WebForm2.aspx> </SECTION> <.SECTION
$.ajax({ type: GET, url: awards.xml, dataType: xml, success: parseXml }); function parseXml(xml) { I
I have the following jQuery $.ajax({ type: GET, url: http://f.cl.ly/items/0i1V1L1k2F440L1m2Y0G/pointdata.xml, dataType: xml, success: parseXml
I am trying to parse some xml data by passing the variables with a
I am having issues with some xml parsing. I want the data to be
This is similar to this question C# Get schema information when validating xml However,
Suppose we have some .xml files containing, amongst other things, MIDI note data. Since
I need help grouping and counting elements from an xml data type column in

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.