473,386 Members | 1,969 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,386 software developers and data experts.

XML serialization attribute help.

I'm building a class with xml serialization attrbutes. Below I've included
the class and the xml it serializes to. It pretty much matches what I want
except for the Message property of the ResultValue class. I want it to
serialize to
<ResultValue><Messages><Message>value</Message><Message>value2</Message></Messages></ResultValue>
but it is actually serializing to
<ResultValue><Messages><string>value</string><string>value2</string></Messages></ResultValue>.
I'm hoping anyone can assist.

The following class:

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://www.test.ca/Schema")]
[System.Xml.Serialization.XmlRootAttribute("Result" ,
Namespace="http://www.test.ca/Schema", IsNullable=false)]
public class ResultValue
{
[System.Xml.Serialization.XmlArray("Messages")] //I must specify this
xmlarray attribute
public string[] Message;

[System.Xml.Serialization.XmlAttributeAttribute()]
public ResultValueType Type;
}

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://www.interiorhealth.ca/Schema")]
public enum ResultValueType
{
Success,
Error,
}

Serializes to this xml:

<?xml version="1.0" ?>
<ResultValue xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Type="Error"
xmlns="http://www.test.ca/Schema">
<Messages>
<string>testtesttst</string>
</Messages>
</ResultValue>
Jun 26 '06 #1
0 977

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

Similar topics

1
by: ofer | last post by:
Hi, I am working with the beta version of the new .net framework (Whidbey) and I encountered a problem with serialization that did'nt exist in the .net 2003 the situation is like this : I have...
3
by: Mark | last post by:
Hello, What I am trying todo is use .NET serialization to take a Guid property that is an attribute in the XML document and have its output to be the same as...
4
by: Jeff T. | last post by:
Hello, I have an existing set of C# classes that encapsulate our application data. They are in a heirachy with each subclass defining more specific types of data. I would like to serialize these...
1
by: Opa | last post by:
Hi I'm having problem serialization an object instance which contains a public property on the object type My object hierarchy is many levels deep, so for simplicty I created to following which...
1
by: Opa | last post by:
Hi I'm having problem serialization an object instance which contains a public property on the object type My object hierarchy is many levels deep, so for simplicty I created to following which...
2
by: ofer | last post by:
Hi, I am working with the beta version of the new .net framework (Whidbey) and I encountered a problem with serialization that did'nt exist in the .net 2003 the situation is like this : I have...
2
by: Vinayak Kamat | last post by:
Hi, I've got two classes - Entity which will have an array of Child objects in it and Child class. class Entity { public Child Children;
1
by: lallous | last post by:
Hello I have the following XML string: <?xml version="1.0" encoding="UTF-8"?> <bool name="value" val="false" display="OFF" href="/value/" xmlns="http://MyObj.org/ns/schema/1.0"...
1
by: kikisan | last post by:
I am developing a windows service which utilizes the following classes: interface IPersistable; abstract class PersistableObject : IPersistable;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.