473,473 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problems Serializing A Collection Object

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">
<AlarmProcessor>
<IP>100.100.100.100</IP>
</AlarmProcessor>
<AlarmProcessor>
<IP>100.100.100.101</IP>
</AlarmProcessor>
</ArrayOfAlarmProcessor>

Class Code============================================== ====

Namespace MyCompany
Public Class AlarmProcessors
Implements ICollection
Private processorIPList As ArrayList = New ArrayList
Public Sub New()
End Sub
Default Public Overloads ReadOnly Property Item(ByVal index As Integer) As AlarmProcessor
Get
Return CType(processorIPList(index), AlarmProcessor)
End Get
End Property
'Code removed for brevity
End Class
End Namespace

Namespace MyCompany
<Serializable(), Xml.Serialization.XmlRoot("Processor")> _
Public Class AlarmProcessor
Private _IP As String
Public Sub New()
End Sub
<Xml.Serialization.XmlElement("IP")> _
Public Property IP() As String
Get
Return Me._IP
End Get
Set(ByVal Value As String)
Me._IP = Value
End Set
End Property
End Class
End Namespace

Any help would be appreciated!

Thanks,
David

=====================
David McCarter
www.vsdntips.com
Nov 12 '05 #1
1 1658
dND,

For examples of serializing arrays and arraylists see
http://www.winisp.net/cheeso/srcview...&file=Array.cs

-Dino
"dotNetDave" <do********@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
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">
<AlarmProcessor>
<IP>100.100.100.100</IP>
</AlarmProcessor>
<AlarmProcessor>
<IP>100.100.100.101</IP>
</AlarmProcessor>
</ArrayOfAlarmProcessor>

Class Code============================================== ====

Namespace MyCompany
Public Class AlarmProcessors
Implements ICollection
Private processorIPList As ArrayList = New ArrayList
Public Sub New()
End Sub
Default Public Overloads ReadOnly Property Item(ByVal index As Integer) As AlarmProcessor Get
Return CType(processorIPList(index), AlarmProcessor)
End Get
End Property
'Code removed for brevity
End Class
End Namespace

Namespace MyCompany
<Serializable(), Xml.Serialization.XmlRoot("Processor")> _
Public Class AlarmProcessor
Private _IP As String
Public Sub New()
End Sub
<Xml.Serialization.XmlElement("IP")> _
Public Property IP() As String
Get
Return Me._IP
End Get
Set(ByVal Value As String)
Me._IP = Value
End Set
End Property
End Class
End Namespace

Any help would be appreciated!

Thanks,
David

=====================
David McCarter
www.vsdntips.com

Nov 12 '05 #2

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

Similar topics

2
by: sam | last post by:
I have a collection of vb.net objects with LoadXML and SaveXML functions which use XML serialization to persist the collection. Is it possible to Update one single object in the collection at a...
1
by: Carl Gilbert | last post by:
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...
3
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...
0
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...
0
by: BergRD | last post by:
Salutations! New to the forums but have gotten many an idea from lurking over the past few months but alas it's time to begin positing; posting to a problem I cannot seem to resolve. This is a...
0
by: Alex Clark | last post by:
Hi all, Apologies for the cross-post but I can't determine if this is a VS .NET problem or a VB.NET language issue. I'm using .NET 1.1 SP1, VS 2003 EA, VB.NET. I'm coding a custom component...
1
by: Alex Clark | last post by:
Hi all, Apologies for the cross-post but I can't determine if this is a VS .NET problem or a VB.NET language issue. I'm using .NET 1.1 SP1, VS 2003 EA, VB.NET. I'm coding a custom component...
4
by: mookid8000 | last post by:
Good day group! I have created a nice filtering plugin system, where all filters derive from a Filter class, and they pass a PictureData object between them. I have a problem though. I am able...
1
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...
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...
1
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...
0
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
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,...
1
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...
0
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...
0
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 ...
0
muto222
php
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.