473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

XML serialisation

M
Hi,

I have a collection of user defined types called
EmployeeCollection which inherits from CollectionBase.
EmployeeCollection is a collection of Employee objects.
When i serialise the collection, the serialized collection
looks like:
<ArrayOfEmployee>
<Employee>
.....
</Employee>
</ArrayOfEmployee>

I tried specifying the XMLRootAttribute for the collection
class, but that gives an error reflecting
EmployeeCollection.
Can anyone please let me know how I can specify my own
element name for the serialised output.

Thanks.
M

Nov 15 '05 #1
1 1434
d2d
Here is what you do for your own tag name for the serialized output.
You could specify your own element name by using "XmlElement" attribute
of type "XmlElementAttribute".

ex)
class A {
private int abc;
[XmlElement("Garbage")]
public in Abc {
// get and set.
}
}

After serializing the class "A",
You will get something like
<A xmlns:xsd=htt.....>
<Garbage>
(Some Garbage integer value)
</Garbage>
</A>

So instead of "Abc", you get the tag named "Garbage" using XmlElement
attribute.

Hope that helped.
M wrote:
Hi,

I have a collection of user defined types called
EmployeeCollection which inherits from CollectionBase.
EmployeeCollection is a collection of Employee objects.
When i serialise the collection, the serialized collection
looks like:
<ArrayOfEmployee>
<Employee>
....
</Employee>
</ArrayOfEmployee>

I tried specifying the XMLRootAttribute for the collection
class, but that gives an error reflecting
EmployeeCollection.
Can anyone please let me know how I can specify my own
element name for the serialised output.

Thanks.
M


Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: unknow | last post by:
I want to do a serialisation in pure C++ but i don't know how. Do you have some useful links ? Thanks
2
by: msnews.microsoft.com | last post by:
Hi Here is another EASY question When you serialise an object in .NET, serialisation adds defaut attributes that I dont care EXEMPLE : <root_test...
1
by: lobrys | last post by:
Hi everybody here is a question I have this class that a want to serialize : Public Class BOO <XmlAttributeAttribute()> Public THING As String <XmlElementAttribute("param")> Public p() As...
2
by: lobrys | last post by:
Hi everybody what are the objets for the folowing XML serialisation : (I have problem with "name" and "datatype") <vehicule type="car"> <name datatype="String">Megane</name> </inventory> ...
0
by: Ollie | last post by:
I have been able to get simple circular references to be serialized in xml by using the ImportTypeMapping method on the SoapReflectionImporter class. But I am unable to serialise circular...
1
by: McGiv | last post by:
Hi, I'm trying to serialise some objects and I've can't get the built in serialisation to output exactly what I want. For the moment I'm implementing the IXmlSerializable interface and doing it...
1
by: BrentonMCA | last post by:
I want to be able to serialise an object and then pass the serialisation text as a string to a Web service without serialising to a file first. I also want to be able to deserialise from the text...
2
by: Greg | last post by:
I have a bizarre situation in which serialisation is failing routinely under a specific condition, and I'm wondering if the details ring a bell with anyone here. I have 2 classes that my...
2
by: ashwinij | last post by:
Hello The steps which i am doing in my program 1) I am having an xml file. 2) I am performing some updations in the file using XQueryUtil class from nux package. 3)After that i am...
1
by: OrionLee | last post by:
I am using C# to work with a 3rd party DLL (Nevron Charts), and attempting to serialise it. The serialisation itself is handled somewhere inside the DLL, so to get it to happen you call the Nevron's...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.