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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:02:42+00:00 2026-05-27T07:02:42+00:00

I have a bunch of objects that were serialized to XML. Now I want

  • 0

I have a bunch of objects that were serialized to XML. Now I want to deserialize them, but since I don’t know what the type is for a given XML string, I can’t figure out how to do it. Here is the code I am using when I know what type (Task in this case) the objects are:

public static Task DeserializeFromXML(string value)
{
  Task task = new Task();
  StringReader reader = new StringReader(value);
  XmlSerializer serializer = new XmlSerializer(task.GetType());
  XmlReader xmlReader = new XmlTextReader(reader);
  task = (Task)serializer.Deserialize(xmlReader);
  return task;
}

I’m confused since XmlSerializer needs a type passed to the constructor and the Deserialize method eventually needs to be cast from Object to whatever I just deserialized, but I don’t know what that type is at this point.

  • 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-27T07:02:42+00:00Added an answer on May 27, 2026 at 7:02 am

    The XML serializer does not include information about the kind of objects that are serialized out. With straight XML, you don’t have a way around this. The object type is not included in the serialization.

    Some other serializers in .NET (notably the NetDataContractSerializer) do include enough information to reconstruct specific object types without knowing them ahead of time.

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

Sidebar

Related Questions

I have a bunch of xml serialized objects in a database. But, I refactored
In C++, say you have a whole bunch of objects that you want to
I have a process in R that creates a bunch of objects, serializes them,
I have a bunch of objects that have a value and a date field:
I have a bunch of different objects that are commonly edited in the same
I have a bunch of Thingy objects that I'm keeping track of using long
I'm working on a project where I have a bunch of objects (same type)
Here's the situation. I have a bunch of objects that implement Serializable that I
I have bunch of objects that return a DOM-tree that I then use to
I have a bunch of objects that inherit abstracts interfaces generated from an idl

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.