473,503 Members | 2,135 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML Serialization

I have created a class that acts as a container for collections of other
classes, and am using the IXMLSerializable interface to custom deserialize
my XML into the class structure. Well, I got the base class and it's
properties working like a charm, but am having difficulty with the other
classes.

My class structure mimics the XML very closely

<Myxmldoc attr1="a" attr2="b" attr3="c">
<subClass1 subattr1="aa" subattr2="bb" subattr3="cc"/>
<subClass2 subattr1="aa" subattr2="bb" subattr3="cc"/>
<subClass3 subattr1="aa" subattr2="bb" subattr3="cc"/>
</Myxmldoc>

So the classes are...

Public Class Myclass
Implements IXMLSerializable

Public Property classattr1() as String
....
End Property

Public Property classattr2() as String
....
End Property

Public Property classattr3() as String
....
End Property

Public Function GetSchema() As XmlSchema
Implements IXmlSerializable.GetSchema
Return Nothing
End Function

Public Sub ReadXml(ByVal reader As XmlReader)
Implements IXmlSerializable.ReadXml
classattr1 = reader.GetAttribute("attr1")
classattr2 = reader.GetAttribute("attr3")
classattr3 = reader.GetAttribute("attr3")
End Sub

Public Sub WriteXml(ByVal writer As XmlWriter)
Implements IXmlSerializable.WriteXml
.....
End Sub
End Class

Public Class Mysubclass
Implements IXMLSerializable

Public Property subclassattr1() as String
....
End Property

Public Property subclassattr2() as String
....
End Property

Public Property subclassattr3() as String
....
End Property

Public Function GetSchema() As XmlSchema
Implements IXmlSerializable.GetSchema
Return Nothing
End Function

Public Sub ReadXml(ByVal reader As XmlReader)
Implements IXmlSerializable.ReadXml
subclassattr1 = reader.GetAttribute("subattr1")
subclassattr2 = reader.GetAttribute("subattr3")
subclassattr3 = reader.GetAttribute("subattr3")
End Sub

Public Sub WriteXml(ByVal writer As XmlWriter)
Implements IXmlSerializable.WriteXml
.....
End Sub
End Class

--------------------------

Now, precisely how I want to declare the Mysubclass collection in Myclass
and how to call on the Mysubclass.ReadXML method from the MyclassXML method
I am unsure of. Any help??


Nov 18 '05 #1
0 742

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

Similar topics

37
4945
by: Ben | last post by:
Hi, there. Recently I was working on a problem where we want to save generic closures in a data structure (a vector). The closure should work for any data type and any method with pre-defined...
1
4349
by: andrewcw | last post by:
There is an error in XML document (1, 2). I used XML spy to create the XML and XSD. When I asked to have the XML validated it said it was OK. I used the .net SDK to generate the class. I have...
3
3155
by: Aaron Clamage | last post by:
Hi, I'm not sure that if this is the right forum, but any help would be greatly appreciated. I am porting some java serialization code to c# and I can't figure out the correct way to do it. ...
6
2701
by: Uttam | last post by:
Hello, We are at a very crucial decision making stage to select between .Net and Java. Our requirement is to download a class at runtime on the client computer and execute it using remoting or...
3
2441
by: Alexander | last post by:
When i store rule on PC with .NET.SP1 i cant restore them from PC without SP1. An i get this Error: System.Runtime.Serialization.SerializationException: Possible Version mismatch. Type...
4
11379
by: mijalko | last post by:
Hi, I have inherited my class from System.Drawing.Printing.PrintDocument and I wish to serialize this object using XmlSerializer. And I get exception "There was an error reflecting type ...". If I...
5
6104
by: Nikola Skoric | last post by:
I ran in Mono a program developed on .NET Framework 2.0 and it ran OK until I tried to desirialize a object. There the program died abruptly dumping this: System.ArgumentOutOfRangeException:...
0
6590
by: bharathreddy | last post by:
Before going to that i want to say few thing on serialization : Serialization is the process of converting an object into a form that can be readily transported. For example, you can serialize an...
1
11044
by: kikisan | last post by:
I am developing a windows service which utilizes the following classes: interface IPersistable; abstract class PersistableObject : IPersistable;
2
5533
by: mkvenkit.vc | last post by:
Hello, I hope this is the right place to post a question on Boost. If not, please let me know where I can post this message and I will do so. I am having a strange problem with std::string as...
0
7205
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
7093
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
7353
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...
0
7468
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...
0
5596
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3180
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...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
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 ...
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.