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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:56:48+00:00 2026-06-04T01:56:48+00:00

I am using XmlSerializer to serialize a class, which has a list of objects

  • 0

I am using XmlSerializer to serialize a class, which has a list of objects
as part of it.Now what is happening is, the child tag names are taking the name from the class name but what i want is it’d take the name from a public field inside child class.Please help, which xml attribute should i use to make it work.

I have this code:

SessionAnalyser sa = new SessionAnalyser();
Circle c = new Circle();
c.Name = "AP";// I want this property as the TAG Name

XML O/P i am getting:

<SessionAnalyser>
<Circle>
<Name>AP</Name>
...
</Circle>
</SessionAnalyser> 

Required XML O/P:

<SessionAnalyser>
<AP>
...
</AP>
</SessionAnalyser> 
  • 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-06-04T01:56:50+00:00Added an answer on June 4, 2026 at 1:56 am

    XmlSerializer does not support that, note least because it would have no way of deserializing it since it can’t know that .Name maps to the AP in <AP> in advance.

    To do that with XmlSerializer you would have to implement IXmlSerializable, which is a lot of work; however, I suspect using something like a DOM (XElement, for example) would be much easier at that point.

    TL;DR; version

    don’t use XmlSerializer for a scenario that XmlSerializer doesn’t help you with

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

Sidebar

Related Questions

I'm currently using an XMLSerializer to serialize a list of a class of my
What is a better approach to serialize custom class: using XMLSerializer or BinarryFormatter and
I have a class that I serialize/deserialize using XmlSerializer . This class contains a
I'm using XmlSerializer to serialize an object that contains a generic list List <ChildBase>
I am using C# and XmlSerializer to serialize the following class: public class Title
When trying to serialize a type (a generic List<T> which T is a class
I'm using XmlSerializer to serialize my object model to XML. At the moment just
Normally, when using the XMLSerializer to automagically serialize an ISerializable object, a .dll file
In C# / .NET 2.0, when I serialize an object using XmlSerializer , what's
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();

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.