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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:14:55+00:00 2026-06-14T02:14:55+00:00

I need to serialize to an array which has multiple non-nested values i.e. <MyArray>

  • 0

I need to serialize to an array which has multiple non-nested values i.e.

 <MyArray>
    <Code>code1</Code>
    <Name>name associated with code 1</Name>
    <Code>code2</Code>
    <Name>name associated with code 2</Name>
    <Code>code3</Code>
    <Name>name associated with code 3</Name>
    <Code>code4</Code>
    <Name>name associated with code 4</Name>
  </MyArray>

I’ve tried various attributes on my array – e.g.

[XmlArray(ElementName="MyArray")]        
[XmlArrayItem(ElementName="")]        
public List<MyPair> MyPairs { get; set; }

NB: the MyPair object contains 2 string properties (Code & Name):

but to no avail, I always get a containing element for each pair (which would normally be better but not what the schema demands – and over which I’ve no control). Any help greatly appreciated.

EDIT This is part of a huge xml document, is it possible to use manual serialization of XElement for 1 part of it and XMLSerialization for the rest?

  • 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-14T02:14:56+00:00Added an answer on June 14, 2026 at 2:14 am

    Just to close this off. I worked around the problem with I think what could be called a bit of a hack as I wanted avoid serializing the entire object graph manually. So:

    • Used xml serialization to serialize to a string
    • Manipulated the string to remove offending extra nested elements
    • Parsed xml entire string to single XElement (required to allow this to be serialized correctly as xml for WCF)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a business class which I need to serialize to xml. It has
I need to serialize array which contains URLs: Array( 'url1' => 'http://www.example.com', 'url2' =>
I need to serialize an object array array<object^>^ in C++/CLI which contains one intPtr
I need to serialize ArrayList<String> arr=new ArrayList<String>(); on server and then send this array
I'm using Marshal.dump to serialize an array of objects, I need to get the
Hi I am trying to serialize an array of objects which are derived from
I need to pass an array of numeric values from jQuery to a php
I need to serialize and unserialize (is that even a word?) an array in
I am making a website and i need to submit multiple values to a
I need to serialize a .NET DateTime value in a protocol buffers message. My

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.