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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:49:49+00:00 2026-05-28T14:49:49+00:00

I need to deserialize the following XML into a C# class: <NodeConfiguration> <DBChange value=2022/>

  • 0

I need to deserialize the following XML into a C# class:

<NodeConfiguration>
    <DBChange value="2022"/>
    <DBChange value="555" />
    <DBChange value="12:00" />
</NodeConfiguration>

To do this I constructed the following classes:

[XmlType("NodeConfiguration")]
public class NodeConfigurationSerialize
{
    public NodeConfigurationSerialize()
    {

    }

    [XmlElement("DBChange")]
    public DBChange[] ChangeList { get; set; }
}

And:

public class DBChange : StringSerializable<DBChange>, IEquatable<DBChange>, IXmlSerializable
{
    private string mValue;


    public string Value
    {
        get { return mValue; }
        set { mValue = value; }
    }

    public void ReadXml(System.Xml.XmlReader reader)
    {
        mValue = reader.GetAttribute("value");
    }

    public void WriteXml(System.Xml.XmlWriter writer)
    {
        writer.WriteAttributeString("value", mValue);
    }

 }

The problem is that whenever I try to deserialize this class using the method:

Deserialize<NodeConfigurationSerialize>(xml, null);

I get a invalid XML error.

How should I write my DBChange and NodeConfigurationSerialize classes so that I can successfully deserialize them from the XML above?

PS: I am using Visual Studio 2010 and .NET Framework 4.0

EDIT 1:

I’ve changed my NodeConfigurationSerialize class to:

[XmlType("NodeConfiguration")]
public class NodeConfigurationSerialize
{
    public NodeConfigurationSerialize()
    {
        ChangeList = new List<DBChange>();
    }

    [XmlElement("DBChange")]
    public List<DBChange> ChangeList { get; set; }
}

And I’ve also done as @woni suggested and added the reader.Read(); to my DBChange class’ ReadXml method. After that everything worked fine!

Thank you all for your answers!

  • 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-28T14:49:50+00:00Added an answer on May 28, 2026 at 2:49 pm

    I have verified your example code and you are getting an InnerException of type System.OutOfMemoryException.

    The Method ReadXml of DBChange class is called in an infinite loop.

    Change this method to the following:

    public void ReadXml(System.Xml.XmlReader reader) {
        mValue = reader.GetAttribute("value");
        reader.Read();
    }
    

    The call of reader.Read() will tell the XmlSerializer to finish reading of the current element and go to the next element in XML-Sequence.

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

Sidebar

Related Questions

Consider the following XML: <a> <b>2</b> <c></c> </a> I need to deserialize this xml
I have this Xml file, and I need to Deserialize it back to a
I have something like the following xml that I need to deserialize (note I
Problem I need a key-value store that can store values of the following form:
I have the following xml that I need to deserialise to an object: <animals>
This is my requirement i need to deserialize an object and then i need
I need to deserialize a GeoJSON JSON object with the Jackson library. In this
Given the following class structure, will Bar serialize/deserialize as expected? public class Foo {
I need to deserialize a complex JSON blob into standard .NET containers for use
I have object XML serialized messages coming into a class called MessageRouter . The

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.