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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:19:27+00:00 2026-05-28T18:19:27+00:00

I have one xml document which I have to deserialize. The document looks something

  • 0

I have one xml document which I have to deserialize.
The document looks something like this

<root>
  <node1>
    <node2>
      <child1>
        <infoNode1 attr="value"/>
                 .
                 .
                 .
      </child1>
      <child2>
         .
         .
      </child2> 
    </node2>
  </node1>
</root>

Only child1 contains information. The way I deserialize it now is that I have one separate class for each node, but I like to have just a class for node2 because all the data is contained there.

Is there any simple way to skip /root/node1? Do I have to implement my own de-serialization for this?

Thanks.

EDIT:

The code I use to perform the deserialization

string path = "file.xml";
RootClass projectDef = null;

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

StreamReader reader = new StreamReader(path);
projectDef = (RootClass)serializer.Deserialize(reader);
reader.Close();
  • 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-28T18:19:28+00:00Added an answer on May 28, 2026 at 6:19 pm

    Serialization/deserialization is for writting and reading the object, or object hierarchy. state. So you need to have all the nodes to fully support serialization.

    But if you just want to read xml and parse it into objects, you dont have to use serialization.

    • You can use LINQ for XML to parse the file and create new objects.
    • You can use XPath to select the node2 elements and create new objects from the node iterator.
    • You can implement IXmlSerializable and skip the unwanted nodes on ReadXml and WriteXml.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file which has many section like the one below: <Operations>
Let's suppose I have xml like this one: <Server Active=No> <Url>http://some.url</Url> </Server> C# class
I have one XML document which I want to store it inside ViewState so
I have the following XML document which I would like to parse into a
I have one huge XML document. I have set of XSL representing each node
Say I have a LINQ-to-XML query that generates an anonymous type like this: var
I'm in a situation where I have a xml document which is going to
need help to read xml file. i have one xml file which i want
I have a document which uses an XML namespace for which I want to
I have an XML document on input which is awfully formatted (it's Delphi project

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.