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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:19:46+00:00 2026-05-12T15:19:46+00:00

I have the following structure in C#: [Serializable] public struct Line { public Line(Point

  • 0

I have the following structure in C#:

[Serializable]
public struct Line
   {
        public Line(Point startPoint, Point endPoint)
        {
            StartPoint = startPoint;
            EndPoint = endPoint;
        } 
        public Point StartPoint;
        public Point EndPoint;
    }

which I use in another class, that is XmlSerializable

[XmlRootAttribute("Drawing")]
public Drawing
{
    [XmlElement("Line")]
    List<Line> lines;   

    //other members...
}

By serializing the Drawing class, I get an xml that describes a Line like this:

<Line>
    <StartPoint>
        <X>13</X>
        <Y>33</Y>
    </StartPoint>
    <EndPoint>
        <X>43</X>
        <Y>63</Y>
    </EndPoint>
</Line>

Is there any way of specifying the xml serialization tags so that a Line is generated in this format:

<Line StartPointX="13" StartPointY="33" EndPointX="43" EndPointY="63"/>
  • 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-12T15:19:47+00:00Added an answer on May 12, 2026 at 3:19 pm

    Put [XmlAttribute] above your X and Y properties (not shown in your example). That should cause them to serialize as attributes instead of elements, and will produce the following XML:

    <Line>
        <StartPoint X="13" Y="33" />
        <EndPoint X="43" Y="63" />
    </Line>
    

    If you are committed to your example output exactly as you specified, you will also have to restructure your object so that your X and Y attributes are named properly, like this:

    [Serializable]
    public struct Line
    {
        [XmlAttribute]        
        public int StartPointX
        [XmlAttribute]        
        public int StartPointY
        [XmlAttribute]        
        public int EndPointX
        [XmlAttribute]        
        public int EndPointY
    }
    

    (Getters and Setters omitted for brevity)

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

Sidebar

Related Questions

I have the following structure public class MyClass : MyBaseClass<System.Int32> { } In a
I have the following entity structure: public class Party { public Int32 PartyId {
I have following structure of my entities: @MappedSuperclass public abstract class BaseEntity { @Id
I have the following structure. public class ToolSettings { public string Extension { get;
I have the following structure: public class A { private javax.swing.JLabel fullName; public class
I have the following structure: class Base { } class Child : Base {
I have the following class structure FlowerDAO with the fields (mapped using Hibernate): id
I have data that has been stored using binary serialization for the following class:
I have the following structure /templates/base.html templates/index.html --- here i have inherited base.html which
I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party

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.