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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:06:43+00:00 2026-06-18T03:06:43+00:00

I have a tried list, array and all different types I have a list

  • 0

I have a tried list, array and all different types

I have a list of items which is serializing just fine

in c#

public mySortableBindingList<Item> TransactionLines = new mySortableBindingList<Item>();

in vb.net

Public WithEvents TransactionLines As New mySortableBindingList(Of Item)

xml output is

<TransactionLines>
   <Item>
    <elements>
   </item>
   <Item>
    <elements>
   </item>
</TransactionLines>

my serilization method is the following

In C#

public string SerializeToXML<T>(T obj)
{
string XMLString = "";
try {
    XmlSerializer mySerializer = new XmlSerializer(obj.GetType());

    using (MemoryStream myMemStream = new MemoryStream()) {
        mySerializer.Serialize(myMemStream, obj);
        myMemStream.SeekToBegin();
        XMLString = myMemStream.ReadToEnd(Encoding.UTF8);
    }
} catch (Exception ex) {

}
return XMLString;
}

In vb.net

 Public Function SerializeToXML(Of T)(ByVal obj As T) As String

        Dim XMLString As String = ""
        Try
            Dim mySerializer As XmlSerializer = New XmlSerializer(obj.GetType)

            Using myMemStream As MemoryStream = New MemoryStream()
                mySerializer.Serialize(myMemStream, obj)
                myMemStream.SeekToBegin()
                XMLString = myMemStream.ReadToEnd(Encoding.UTF8)
            End Using
        Catch ex As Exception

        End Try
        Return XMLString
    End Function

List to be serialized

c#

[XmlElement(Order = 17)]
public mySortableBindingList<ItemSerial> Serials = new mySortableBindingList<ItemSerial>();

vb.net

<XmlElement(Order:=17)>
Public Serials As New mySortableBindingList(Of ItemSerial)

This is my xml output

<Serials>
   <Serial>A</Serial>
   <ExpiryDate>0001-01-01T00:00:00</ExpiryDate>
   <Qty>1</Qty>
</Serials>
<Serials>
   <Serial>B</Serial>
   <ExpiryDate>0001-01-01T00:00:00</ExpiryDate>
   <Qty>1</Qty>
</Serials>

I need the following please explain what I can be doing wrong

  <Serials>
   <ItemSerial>
      <Serial>A</Serial>
      <ExpiryDate>0001-01-01T00:00:00</ExpiryDate>
      <Qty>1</Qty>
   </ItemSerial>
   <ItemSerial>
      <Serial>B</Serial>
      <ExpiryDate>0001-01-01T00:00:00</ExpiryDate>
      <Qty>1</Qty>
   </ItemSerial>
</Serials>
  • 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-18T03:06:44+00:00Added an answer on June 18, 2026 at 3:06 am

    From Richards answer I found that I could use XMLArray attribute which will infer that it is a list and therefore be serialized in the manner I required.

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

Sidebar

Related Questions

I have code that stores matrices of different types, e.g. m1: Array[Array[Double]], m2: List[List[Int]]
I have tried to do this refering to following link. http://skypher.com/index.php/2008/07/28/function-list-for-php/ But no success.
i have to show 3 columns in List view. I tried having table inside
I have tried many permutations but they all don't seems to work well. Am
I have tried a variety of different solutions found on stack and other places
Possible Duplicate: sort array list of special strings, by date I have an ArrayList
I have a list of 120 million records of around 40/50 bytes each which
I have a list of optional clothing items as checkboxes, there may be a
I have to safely free an array: char** a; It's like a string list.
Im trying to add an array to a webpage. I have tried a few

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.