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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:53:58+00:00 2026-05-27T05:53:58+00:00

Trying to deserialize an XML file from a 3rd party tool into a custom

  • 0

Trying to deserialize an XML file from a 3rd party tool into a custom software class. The problem is that the XML is a little goofy as the “root” item is really the declaration of the collection. I have done a lot with XMLArray and other definitions to define serialization, but this does not seem to work. The best I have been able to do is to get the collection read in but none of the objects in the collection are initialized with the variables.

Here is an example of what I am facing:

XML:

<Animals>
  <Animal>
    <Name>Mr. Cow</Name>
    <Type>Cow</Type>
  </Animal>
  <Animal>
    <Name>Belle</Name>
    <Type>Cow</Type>
  </Animal>
  <Animal>
    <Name>Porky</Name>
    <Type>Pig</Type>
  </Animal>
</Animals>

I then have my XMLRoot defined as “Animals” in my “Farm” object. And have a list property for my class of “Animal”. If I define that property (list AnimalCollection) the best I can get is a list of 3 uninitiated Animal objects (none of the values set).

Around the office, the best we could figure to do was to add a node to the file as a stream before trying to deserialize it and use it business as usual, but obviously this seems like a horrible hack. Hoping that there is a better way that I am just missing.

I have also thought about manually reading the document as well… but again hoping there is a more elegant way.

  • 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-27T05:53:59+00:00Added an answer on May 27, 2026 at 5:53 am
    XmlSerializer serializer = new XmlSerializer(typeof(Animal[]), new XmlRootAttribute("Animals"));
    
    public class Animal
    {
        [XmlElement]
        public string Name;
        [XmlElement]
        public string Type;
    }
    
    • 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 an XML file into a few class objects: Artist,
I'm trying to deserialize an XML that comes from a web service but I
I have a simple class that I trying to populate from an XML document.
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'm trying to write a generic method that can be used to deserialize xml
I'm trying to teach-myself how to serialize/deserialize to/from XML using the attribute-based serializer. I've
I am trying to deserialize a XML-file. I need to check if the XML-file
i have a problem when i trying to use XmlSerializer to deserialize an xml
I have an XML file that I deserialize, the funny part is the XML

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.