473,761 Members | 4,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serializing a collection

Hi

I am trying to serialize a collection of GUIDs by overriding the
serialize function on a diagram component I am using.
The following code sucessfully serializes a single GUID:

Public Overloads Overrides Function Serialize(ByVal Key As Object) As
String
Dim objXML As New XmlDocument
Dim objParent As XmlElement
objParent = objXML.CreateEl ement("Interact ionShape")
objParent.SetAt tribute("Intera ctionGUID", _
m_InteractionGU ID.ToString) <-----change to
collection
objParent.Inner Xml = MyBase.Serializ e(Key)
Return objParent.Outer Xml
End Function

Which gives the following XML: (some XML deleted)

<InteractionSha pe InteractionGUID ="50179760-9d24-4239-8029-0fb08be7630b">
</InteractionShap e>


Does anyone know how to serialize a collection (where
m_InteractionGU ID is a strongly typed collection of GUIDs rather than
a single GUID) to give something like the following XML?

<InteractionSha pe>
<InteractionGUI D GUID="50179760-9d24-4239-8029-0fb08be7630b">
<InteractionGUI D GUID="84611660-9d45-3575-3545-0bb08be5816f">
</InteractionShap e>

- OR -

<InteractionSha pe>
<InteractionGUI D>50179760-9d24-4239-8029-0fb08be7630b</InteractionGUID >
<InteractionGUI D>84611660-9d45-3575-3545-0bb08be5816f</InteractionGUID >
</InteractionShap e>

Kind regards, Carl
Nov 12 '05 #1
1 2889
You are building a DOM object and generating XML from it.

There is a different approach which is to deal with domain-specific objects,
and use the XML-serialization capabilities built into the .NET Framework to
generate the XML for you. In this way the XML is less intrusive into your
app. You still get the capability to read and write XML, but it is done
more implicitly.

For an example of serializing a strongly-typed collection of Guids, see
http://www.winisp.net/cheeso/srcview...ile=collect.vb
-D
"Carl Gilbert" <mr************ *@hotmail.com> wrote in message
news:66******** *************** ***@posting.goo gle.com...
Hi

I am trying to serialize a collection of GUIDs by overriding the
serialize function on a diagram component I am using.
The following code sucessfully serializes a single GUID:

Public Overloads Overrides Function Serialize(ByVal Key As Object) As
String
Dim objXML As New XmlDocument
Dim objParent As XmlElement
objParent = objXML.CreateEl ement("Interact ionShape")
objParent.SetAt tribute("Intera ctionGUID", _
m_InteractionGU ID.ToString) <-----change to
collection
objParent.Inner Xml = MyBase.Serializ e(Key)
Return objParent.Outer Xml
End Function

Which gives the following XML: (some XML deleted)

<InteractionSha pe InteractionGUID ="50179760-9d24-4239-8029-0fb08be7630b">
</InteractionShap e>


Does anyone know how to serialize a collection (where
m_InteractionGU ID is a strongly typed collection of GUIDs rather than
a single GUID) to give something like the following XML?

<InteractionSha pe>
<InteractionGUI D GUID="50179760-9d24-4239-8029-0fb08be7630b">
<InteractionGUI D GUID="84611660-9d45-3575-3545-0bb08be5816f">
</InteractionShap e>

- OR -

<InteractionSha pe>
<InteractionGUI D>50179760-9d24-4239-8029-0fb08be7630b</InteractionGUID > <InteractionGUI D>84611660-9d45-3575-3545-0bb08be5816f</InteractionGUID > </InteractionShap e>

Kind regards, Carl

Nov 12 '05 #2

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

Similar topics

1
1688
by: dotNetDave | last post by:
I'm trying to create xml seriaizable collection class (below), but the xml keeps coming out wrong. In the resulting xml from the web service (below) the "ArrayOfAlarmProcessor" tag should really be "Processors" and the "AlarmProcessor" tag should be "Processor". <ArrayOfAlarmProcessor xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://mycompany/webservice/NetworkAlarms">...
3
2615
by: Amy L. | last post by:
I am using the xml serializer to serialize the objects out of a collection into a file. The object that is being serialized is a class in my application. When I serialize my class it produces the following line. <?xml version="1.0" encoding="utf-16"?> for each instance of my serialized class. Thus giving me the following output.
2
3299
by: Aleksei Guzev | last post by:
Imagine one writing a class library CL1 for data storage. He defines classes ‘DataItem’ and ‘DataRecord’ so that the latter contains a collection of the former. And he derives class ‘IntItem’ from ‘DataItem’ public class DataItem { public DataItem() {}
0
1625
by: JackRazz | last post by:
I'm trying to serialize a collection to a file stream by serializing each object individually. The code below works fine with the BinaryFormatter, but the SoapFormatter reads the first object and just goes to the end of the file. After reading the first object, the fStream.Position is pointed to the end of the file. The collection serializes/deserilizes fine when I just serialize the hashtable vs. each object in the hashtable. Does...
0
1112
by: Michael Maercker | last post by:
Hi! I'm about to go nuts over my serializing problem. This is my situation: I have a Data-Class that can have children of the same class which are stored in a hashtable, i.e: X has A as a child A has B as a child When an object is changed it raises an Updated-Event which the
3
6876
by: axr | last post by:
Having trouble with Serilization of objects that contain members which are of type Interface eg public class SomeClass { ISomeInterface1 itf1; ClassType1 ct1; ISomeInterface2 itf2;
3
11760
by: RandomEngineer | last post by:
So here's the challenge... How can a collection (System.Collections.Generic.IList) of some custom type be serialized in a web service using .NET 2.0? Below are the class and the web methods in question. The interesting thing is that at each step of the way, DAL & Biz, the someType class is decorated with the Serializable attribute. And the someTypes collection in the web method is correctly populated with the data after the call to...
0
1214
by: Yofnik | last post by:
Is there a way to avoid serializing an empty ArrayList? I would like the following class: public class Collection { public ArrayList Items = new ArrayList(); } ....to serialize like this:
1
1248
by: Karthik1979 | last post by:
I have a custom class inherited from List<T> collection. Along with the base class functionality, I have included my additional properties. When serializing, only the base class items are serialized not my additional properties. I have designed a business object collection like this and I have to pass it across the service layer. But in another end I’m getting partial data not all my information is getting de-serialized. Here is a sample...
0
9336
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
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
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...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8770
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
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
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2738
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.