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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:12:14+00:00 2026-06-02T15:12:14+00:00

I am trying to create an xml doc by serializing objects. I came across

  • 0

I am trying to create an xml doc by serializing objects. I came across an issue.

Target xml structure is similar to an HTML page. It has a form element with some attributes
and can have any number of controls like textfields, buttons etc. Object I create for this structure is given below. To add all these controls I am using an array list called items. When the object is seraialzed all the controls appear inside the tags . I want the controls appear as the direct child of form elements. How can I do this?

   [XmlInclude(typeof(Lstatic))]

    [XmlInclude(typeof(textField))]

    public class form
    {
        [XmlAttribute]
        public String action
        {
            get;
            set;
        }

        [XmlAttribute]
        public String method
        {
            get;
            set;
        }

        [XmlAttribute]
        public String name
        {
            get;
            set;
        }

        [XmlArray]
        public ArrayList items
        {
            get;
            set;
        }

    }

and this is the resulting XML

<form name="login" method="get" action="/FetchIndex.asmx/findAddresses"> 
<items> 
<anyType value="Please key in your details:" xsi:type="Lstatic"/> 
<anyType name="postCode" value="" xsi:type="textField" size="10" label="Postcode:" hint="Enter your postcode"/> 
</items> 
</form>

Instead I want the resulting xml like this

<form name="login" method="get" action="/FetchIndex.asmx/findAddresses"> 

    <anyType value="Please key in your details:" xsi:type="Lstatic"/> 
    <anyType name="postCode" value="" xsi:type="textField" size="10" label="Postcode:" hint="Enter your postcode"/> 

    </form>

How can i do this in c#?
Thanks

  • 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-02T15:12:16+00:00Added an answer on June 2, 2026 at 3:12 pm

    This code is untested, sorry, it is only what I remember. I believe you need the XmlElement attribute.

    [XmlElement("AnyType")]
    public object[] itemsSerializable
    {
        get { return items.ToArray(); }
        set { items = new ArrayList(value); }
    }
    
    [XmlIgnore]
    public ArrayList items
    {
        get;
        set;
    }
    

    If it works, there’s a possibility it might also work without the need of the itemsSerializable property, you should check it out.

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

Sidebar

Related Questions

I'm trying to create an XML sitemap using CakePHP, from a table which has
I am trying to create a winform application that searches through an XML doc.
I'm trying to create a simple XML parser where each different XML schema has
I am trying to create an XML file, but the XML file needs to
I'm trying to create an xml entry that looks like this using python and
I am trying to create an XML file to conform to someones XSD this
I have been trying to create an XML using the simplexml library (v2.6.2) http://simple.sourceforge.net/home.php
I'm trying to create a large XML tree in R. Here's a simplified version
I'm trying to create an element in an XML where the basic content is
I am trying to create an XSD schema which will validate the following xml.

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.