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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:53:18+00:00 2026-05-30T20:53:18+00:00

I am trying to deserialize a XML, however I am having a lot of

  • 0

I am trying to deserialize a XML, however I am having a lot of problems with the List object that I am using.

The XML is the following:

<EntriesSerialize>
    <Entries>
        <Entry file="myFile"
        value="2000" />
        <Entry file="myFile"
        value="400" />
        <Entry file="myFile"
        value="200" />
    </Entries>
</EntriesSerialize>

My classes are:

[XmlType("Entry")]
public class Entry
{
    public Entry()
    {

    }

    [XmlAttribute("file")]
    public string File { get; set; }

    [XmlAttribute("value")]
    public string Value { get; set; }

 }

[XmlType("EntriesSerialize")]
public class EntriesSerialize
{
    public EntriesSerialize()
    {
        EntriesList = new List<Entry>();
    }

    [XmlElement("Entries")]
    public List<Entry> EntriesList { get; set; }

}

The code that I am using to deserialize this XML is:

public static T Deserialize<T>(string content)
{
    byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(content);
    MemoryStream stream = new MemoryStream(byteArray);
    StreamReader reader = new StreamReader(stream);

    XmlSerializer serializer;
    serializer = new XmlSerializer(typeof(T));

    T model = (T)serializer.Deserialize(reader);
    reader.Close();

    return model;
}

The method that I call in the deserialization is the Deserialize(string content) like this:

EntriesSerialize temp = Deserialize<EntriesSerialize>(data);

However when I look at the temp variable using the C# debugger, I see that there is only one element inside the EntriesList object and that this element has its file and value attributes as null.

Note: the serialization of those classes works as expected.

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

    The attribute(s) on EntriesList should be:

    [XmlArray("Entries"), XmlArrayItem("Entry")]
    public List<Entry> EntriesList { get; set; }
    

    Your current syntax with [XmlElement("Entries")] is configured for:

    <EntriesSerialize>
        <Entries file="myFile" value="2000" />
        <Entries file="myFile" value="400" />
        <Entries file="myFile" value="200" />
    </EntriesSerialize>
    

    (for info, neither of the [XmlType("...")] attributes are used in this scenario, but they don’t do any harm either)

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

Sidebar

Related Questions

I am trying to deserialize the following xml structure into an object... <?xml version=1.0
I'm trying to deserialize an object back from it's XML string using xmlSerializer.Deserialize() but
I have an xml file like the following that I'm trying to deserialize. <info>
I'm trying to deserialize an xml structure that looks like this: <somecontainer> <key1>Value1</key1> <key1>Value2</key1>
I am trying to deserialize an object from XML in Ruby. Something simple like:
I am trying to deserialize a list of key value pairs that represent a
I'm trying to deserialize an XML that comes from a web service but I
I'm trying to write a generic method that can be used to deserialize xml
I'm trying to deserialize the following XML output: <?xml version=1.0 encoding=ISO-8859-1?> <Foo> <Val>Data1</Val> </Foo>
I am trying to deserialize some xml into an IList, but I am having

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.