473,799 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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><M essages><Messag e>value</Message><Messag e>value2</Message></Messages></ResultValue>
but it is actually serializing to
<ResultValue><M essages><string >value</string><string> value2</string></Messages></ResultValue>.
I'm hoping anyone can assist.

The following class:

[System.Xml.Seri alization.XmlTy peAttribute(Nam espace="http://www.test.ca/Schema")]
[System.Xml.Seri alization.XmlRo otAttribute("Re sult",
Namespace="http ://www.test.ca/Schema", IsNullable=fals e)]
public class ResultValue
{
[System.Xml.Seri alization.XmlAr ray("Messages")] //I must specify this
xmlarray attribute
public string[] Message;

[System.Xml.Seri alization.XmlAt tributeAttribut e()]
public ResultValueType Type;
}

[System.Xml.Seri alization.XmlTy peAttribute(Nam espace="http://www.interiorhea lth.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>testtes ttst</string>
</Messages>
</ResultValue>
Jun 26 '06 #1
0 991

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

Similar topics

1
1499
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 a class that inherits from dataset, and I want to serialize it , so I created a serialization constructor that forwards the call to the base class (the dataset) serialization constructor, normally, for this action to succeed I am supposed to put...
3
2365
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 Guid.NewGuid().ToString().ToUpper().Replace("-","") I have a working copy of this type of class that will work generating an element with the output i have and the following is an example of that code. What i run into is making the element an attribute then it breaks and does not...
4
3137
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 data objects as XML but perserve the relationships in the XML document. For example, if my classes were: public class GenericItem { }
1
2642
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 produces the same error Let's say there is a class called ParkingSpot with a public member Vehicle having an object type of object For simplicity, let's say that Vehicle could be anything, hence I create a new object of Car typ and assign it to...
1
2866
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 produces the same error Let's say there is a class called ParkingSpot with a public member Vehicle having an object type of object For simplicity, let's say that Vehicle could be anything, hence I create a new object of Car typ and assign it to...
2
2358
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 a class that inherits from dataset, and I want to serialize it , so I created a serialization constructor that forwards the call to the base class (the dataset) serialization constructor, normally, for this action to succeed I am supposed to put...
2
10421
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
1902
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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://MyObj.org/ns/schema/1.0 /MyObj/xsd"/>
1
11111
by: kikisan | last post by:
I am developing a windows service which utilizes the following classes: interface IPersistable; abstract class PersistableObject : IPersistable;
0
9543
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.