By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,107 Members | 1,617 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,107 IT Pros & Developers. It's quick & easy.

Problems Serializing A Collection Object

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.