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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:38:08+00:00 2026-06-09T20:38:08+00:00

I am playing around with this simple tutorial in C# and here is the

  • 0

I am playing around with this simple tutorial in C# and here is the kind of XML you can GET.

    <Person xmlns="http://schemas.datacontract.org/2004/07/RESTfulDemo" 
      xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <Age>23</Age>
      <ID>1</ID>
      <Name>Bob Kohler</Name>
    </Person>

Here is the Person.cs class :

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Runtime.Serialization;

    namespace RESTfulDemo
    {   

      [DataContract]
      public class Person
      {
         [DataMember]
         public string ID;

         [DataMember]
         public string Name;

         [DataMember]
         public string Age;
      }
    }

1) How should can I add attributes / Prefixes in my XML for each data member ?

2) How can I set the heading of my XML to this (or anything else) :

    <?xml version="1.0"?>
  • 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-09T20:38:09+00:00Added an answer on June 9, 2026 at 8:38 pm

    So, here is what I did to overcome this problem. The solution does not involve Serialization but at least it enables to format the response like you want.

    • (1) Put XElement from System.xml.linq as return type of each method and build the xml with the XElement class in each method.
    • (2) Use exactly the code provided here to add the xml declaration on top of your xml response. Thanks to @Dash for the link.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am playing around with HTML 5 apps according to this tutorial: http://sixrevisions.com/web-development/html5-iphone-app/ It's
I was playing around with recursion and did this simple function. I was assuming
Been playing around with this for a couple of hours and can't seem to
I was playing around with this script of auto scrolling text. You can check
I've been playing around with Simple.Data and have run across something that I can't
I've been playing around with this for a couple of hours and have come
Update: After playing around with this for a few hours, went with a multi-query
Pleasantries I've been playing around with this idea for a couple of days but
UPDATE: I've been playing around with this more, and it seems like tmux's clear-history
After playing around with haskell a bit I stumbled over this function: Prelude Data.Maclaurin>

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.