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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:15:33+00:00 2026-06-13T11:15:33+00:00

Playing around with the Web API with Framework 4.0 Wanted XML only output, so

  • 0

Playing around with the Web API with Framework 4.0
Wanted XML only output, so removed the JSON formatter from the formatters collection.
Now, I’d like to modify the standard XML that the XMLSerializer is outputting:

<?xml version="1.0"?>
-<ArrayOfCategory xmlns:xsd="http://www.w3.org/2001/XMLSchema"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">-
  <Category>
    <Id>1</Id>
    <Name>Drink</Name>
  </Category>-
  <Category>
    <Id>2</Id>
    <Name>Snack</Name>
  </Category>
</ArrayOfCategory>

I’d like to change the “Arrayof” node to say something more meaningful, and need to add a couple more nodes (with extra information) above the “Arrayof” node.

Is there an easy way to do this? or do I have to write a custom formatter/seralizer?

  • 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-13T11:15:34+00:00Added an answer on June 13, 2026 at 11:15 am

    I’d like to change the “Arrayof” node to say something more meaningful, and need to add a couple more nodes (with extra information) above the “Arrayof” node.

    If you want this kind of customization of your XML, you should use the the XmlSerializer instead of the DataContractSerializer that is used by default in the XmlFormatter.

    config.Formatters.XmlFormatter.UseXmlSerializer = true;
    

    Then, you can wrap your collection of Category into a class and use [XmlRoot], [XmlElement], and [XmlArray] to customize the element name. Here is an example:

    [XmlRoot(ElementName = "node")]
    public class Node
    {
        [XmlElement(ElementName= "SomeInfo")]
        public string Node1;
    
        [XmlElement(ElementName = "OtherInfo")]
        public string Node2;
    
        [XmlArray("Categories")]
        public List<Category> CatList;
    }
    

    For more info, you can refer to this MSDN article: Controlling XML Serialization Using Attributes.

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

Sidebar

Related Questions

I'm actually playing around with the last.FM web serivce API which I call via
I'm playing around with the new mvc web api and knockout.js and came across
I'm playing around with this Google Web toolkit/GSON example that gets data from twitter.
Im playing around with web.py as a lightweight web framework. Im having problems when
So I've been playing around with the latest release of the WCF Web API
I come from a web-development background. I've been playing around with a bit of
I'm playing around with deriving from System.Web.UI.WebControls.Table/Cell/Row and can't get HtmlTextWriter.AddAttribute to work: Table:
I'm playing around with writing some simple Spring-based web apps and deploying them to
I playing around with the Twitter API for my BlackBerry application. Is there any
I'm playing around with using amazon web services in my personal project. I've grabbed

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.