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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:12:47+00:00 2026-05-11T05:12:47+00:00

I have a web service that has an input object similar to the following.

  • 0

I have a web service that has an input object similar to the following.

public class MyInput {     [System.Xml.Serialization.XmlArrayItem('Demographic')]     public DemographicsInfo[] Demographics {get; set;} } 

With the definition of the DemographicsInfo class like this.

public class DemographicsInfo {     [System.Xml.Serialization.XmlAttributeAttribute()]     public string Name { get; set; }     public string Value { get; set; } } 

Right now this generates an XML structure like this.

<Demographics>     <Demographic Name='String'>         <value>string</value>     </Demographic>     <Demographic Name='String'>         <value>string</value>     </Demographic> </Demographics> 

I need to get it into this

<Demographics>     <Demographic Name='String'>string</Demographic>     <Demographic Name='String'>string</Demographic> </Demographics> 

For the life of me, I cannot seem to find the proper attribute(s) to apply to get this format. Does anyone have any advice?

  • 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. 2026-05-11T05:12:48+00:00Added an answer on May 11, 2026 at 5:12 am

    If you know the structure you want, the simplest option is to work back from the xml; write the xml into a file (foo.xml in my case), then (at the command line):

    xsd foo.xml xsd foo.xsd /classes 

    Then look at foo.cs to see how it can be done; it turns out that you simply mark the value with [System.Xml.Serialization.XmlTextAttribute()].

    Here’s the xsd output:

    //------------------------------------------------------------------------------ // <auto-generated> //     This code was generated by a tool. //     Runtime Version:2.0.50727.3053 // //     Changes to this file may cause incorrect behavior and will be lost if //     the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------  using System.Xml.Serialization;  //  // This source code was auto-generated by xsd, Version=2.0.50727.3038. //    /// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute('xsd', '2.0.50727.3038')] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute('code')] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] [System.Xml.Serialization.XmlRootAttribute(Namespace='', IsNullable=false)] public partial class Demographics {      private DemographicsDemographic[] itemsField;      /// <remarks/>     [System.Xml.Serialization.XmlElementAttribute('Demographic', Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]     public DemographicsDemographic[] Items {         get {             return this.itemsField;         }         set {             this.itemsField = value;         }     } }  /// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute('xsd', '2.0.50727.3038')] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute('code')] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class DemographicsDemographic {      private string nameField;      private string valueField;      /// <remarks/>     [System.Xml.Serialization.XmlAttributeAttribute()]     public string Name {         get {             return this.nameField;         }         set {             this.nameField = value;         }     }      /// <remarks/>     [System.Xml.Serialization.XmlTextAttribute()]     public string Value {         get {             return this.valueField;         }         set {             this.valueField = value;         }     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web service client that has an Authenticator class. The Authenticator requires
I have a simple web service that has an API third party developers are
I have a WCF Web Service that has no concurrency configuration in the web.config,
I have a JAX-WS web service that has been running in a production environment
I have a .Net 4 project that has to consume a SOAP Web Service.
I have web service urls that were working fine and are now returning the
I have a web service that returns this string via the jQuery $.ajax() call
I have a web service that requires a two part query to fully get
I have a web service that requires special headers to be sent in the
I have a web service that stores data in a local SQL Server 2008

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.