Using VB.NET I want to read in an XML file that has an array of objects and
then step through the resulting array in code. I build a class to define the
structure and I am running code to read in the data but I can't figure out
where the data is in the resulting array. Most of the relevant code is
below. When I run the code to desrialize I get no errors but if I try to
look at some of the data via the command window I get errors such as this:
?judges2.Judges(0).JudgeFirstName
Index '0' for dimension '0' is out of range.
What am I missing here?
Wayne
================= Execution Code =======================
Private Sub btnImport_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnImport.Click
ReadJudgesTable("c:\2005 WGI\WGI Tabulation Program\Data
Files\data\JudgesTable.xml")
End Sub
Protected Sub ReadJudgesTable(ByVal filename As String)
Dim ser As New XmlSerializer(GetType(ArrayOfJudgeTableEntity))
' Read In the Judges table
Dim fs2 As New FileStream(filename, FileMode.Open)
' Deserialize into another instance of ArrayOfJudgeTableEntity
Dim judges2 As ArrayOfJudgeTableEntity = CType(ser.Deserialize(fs2),
ArrayOfJudgeTableEntity)
fs2.Close()
MsgBox("JudgesTable has been deserialized - I hope",
MsgBoxStyle.Exclamation, "Got Judges")
End Sub
================================================== ==
================== Class Definition ==================
Imports System.Xml
Imports System.Xml.Serialization
Imports System.Collections
Public Class ArrayOfJudgeTableEntity
<XmlArray("JudgeTableEntity"), XmlArrayItem("Judge", IsNullable:=True)> _
Public Judges() As Judge
Public Sub New()
End Sub 'New
'Public Sub New(ByVal id As String, ByVal fn As String, ByVal ln As String,
ByVal type As String)
' JudgeID = id
' JudgeFirstName = fn
' JudgeFirstName = ln
' JudgeType = type
'End Sub 'New
End Class 'ArrayOfJudgeTableEntity
Public Class Judge
Public JudgeID As String
Public JudgeFirstName As String
Public JudgeLastName As String
Public JudgeType As String
Public Sub New()
End Sub 'New
Public Sub New(ByVal id As String, ByVal fn As String, ByVal ln As String,
ByVal type As String)
JudgeID = id
JudgeType = type
JudgeFirstName = fn
JudgeLastName = ln
End Sub 'New
End Class 'Judge
====================================
=========== Sample XML Data ================
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfJudgeTableEntity xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<JudgeTableEntity>
<JudgeId>63371991-cdf9-4cc5-99c1-a42c599498f8</JudgeId>
<JudgeFirstName>Kristen</JudgeFirstName>
<JudgeLastName>O'Melia</JudgeLastName>
<JudgeType>Equipment</JudgeType>
</JudgeTableEntity>
<JudgeTableEntity>
<JudgeId>ce2c0c6e-4094-43da-9d8c-9726d81b017e</JudgeId>
<JudgeFirstName>Smith</JudgeFirstName>
<JudgeLastName>Dan</JudgeLastName>
<JudgeType>Movement</JudgeType>
</JudgeTableEntity>
<JudgeTableEntity>
<JudgeId>efe977f6-04ec-4a65-ae46-34b0f75de87f</JudgeId>
<JudgeFirstName>Kathy</JudgeFirstName>
<JudgeLastName>Whitcomb</JudgeLastName>
<JudgeType>Ensemble Color Guard</JudgeType>
</JudgeTableEntity>
<JudgeTableEntity>
<JudgeId>99d92f77-39e1-46b8-b9e2-446b8cea1b0c</JudgeId>
<JudgeFirstName>Shirlee</JudgeFirstName>
<JudgeLastName>Whitcomb</JudgeLastName>
<JudgeType>General Effect Color Guard</JudgeType>
</JudgeTableEntity>
<JudgeTableEntity>
<JudgeId>f7ae92ef-9bb2-48fe-bbe8-3c566b924d0f</JudgeId>
<JudgeFirstName>George</JudgeFirstName>
<JudgeLastName>Oliviero</JudgeLastName>
<JudgeType>General Effect Color Guard</JudgeType>
</JudgeTableEntity>
<JudgeTableEntity>
<JudgeId>5e1cad18-4ef9-4625-99c2-ee12c2b05cda</JudgeId>
<JudgeFirstName>Lee</JudgeFirstName>
<JudgeLastName>Carpenter</JudgeLastName>
<JudgeType>Penalty</JudgeType>
</JudgeTableEntity>
</ArrayOfJudgeTableEntity>
========================================== 4 7490
Wayne,
It's hard to tell what's going on without seeing code and/or XML. I have
a tutorial on serializing and deserializing arrays at [0]. Take a look
and feel free to post back if you have additional questions.
HTH,
Christoph Schittko
MVP XML http://weblogs.asp.net/cschittko -----Original Message----- From: Wayne Wengert [mailto:wa***************@wengert.com] Posted At: Monday, January 24, 2005 5:25 AM Posted To: microsoft.public.dotnet.xml Conversation: Deserializing an array Subject: Deserializing an array
Using VB.NET I want to read in an XML file that has an array of
objects and then step through the resulting array in code. I build a class to
define the structure and I am running code to read in the data but I can't figure
out where the data is in the resulting array. Most of the relevant code is below. When I run the code to desrialize I get no errors but if I try
to look at some of the data via the command window I get errors such as
this: ?judges2.Judges(0).JudgeFirstName
Index '0' for dimension '0' is out of range. What am I missing here? Wayne ================= Execution Code =======================
Private Sub btnImport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImport.Click
ReadJudgesTable("c:\2005 WGI\WGI Tabulation Program\Data Files\data\JudgesTable.xml")
End Sub
Protected Sub ReadJudgesTable(ByVal filename As String)
Dim ser As New XmlSerializer(GetType(ArrayOfJudgeTableEntity))
' Read In the Judges table
Dim fs2 As New FileStream(filename, FileMode.Open)
' Deserialize into another instance of ArrayOfJudgeTableEntity
Dim judges2 As ArrayOfJudgeTableEntity = CType(ser.Deserialize(fs2), ArrayOfJudgeTableEntity)
fs2.Close()
MsgBox("JudgesTable has been deserialized - I hope", MsgBoxStyle.Exclamation, "Got Judges")
End Sub
================================================== ==
================== Class Definition ==================
Imports System.Xml
Imports System.Xml.Serialization
Imports System.Collections
Public Class ArrayOfJudgeTableEntity
<XmlArray("JudgeTableEntity"), XmlArrayItem("Judge",
IsNullable:=True)> _ Public Judges() As Judge
Public Sub New()
End Sub 'New
'Public Sub New(ByVal id As String, ByVal fn As String, ByVal ln As String, ByVal type As String)
' JudgeID = id
' JudgeFirstName = fn
' JudgeFirstName = ln
' JudgeType = type
'End Sub 'New
End Class 'ArrayOfJudgeTableEntity
Public Class Judge
Public JudgeID As String
Public JudgeFirstName As String
Public JudgeLastName As String
Public JudgeType As String
Public Sub New()
End Sub 'New
Public Sub New(ByVal id As String, ByVal fn As String, ByVal ln As
String, ByVal type As String)
JudgeID = id
JudgeType = type
JudgeFirstName = fn
JudgeLastName = ln
End Sub 'New
End Class 'Judge
==================================== =========== Sample XML Data ================
<?xml version="1.0" encoding="utf-8"?> <ArrayOfJudgeTableEntity xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <JudgeTableEntity> <JudgeId>63371991-cdf9-4cc5-99c1-a42c599498f8</JudgeId> <JudgeFirstName>Kristen</JudgeFirstName> <JudgeLastName>O'Melia</JudgeLastName> <JudgeType>Equipment</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>ce2c0c6e-4094-43da-9d8c-9726d81b017e</JudgeId> <JudgeFirstName>Smith</JudgeFirstName> <JudgeLastName>Dan</JudgeLastName> <JudgeType>Movement</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>efe977f6-04ec-4a65-ae46-34b0f75de87f</JudgeId> <JudgeFirstName>Kathy</JudgeFirstName> <JudgeLastName>Whitcomb</JudgeLastName> <JudgeType>Ensemble Color Guard</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>99d92f77-39e1-46b8-b9e2-446b8cea1b0c</JudgeId> <JudgeFirstName>Shirlee</JudgeFirstName> <JudgeLastName>Whitcomb</JudgeLastName> <JudgeType>General Effect Color Guard</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>f7ae92ef-9bb2-48fe-bbe8-3c566b924d0f</JudgeId> <JudgeFirstName>George</JudgeFirstName> <JudgeLastName>Oliviero</JudgeLastName> <JudgeType>General Effect Color Guard</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>5e1cad18-4ef9-4625-99c2-ee12c2b05cda</JudgeId> <JudgeFirstName>Lee</JudgeFirstName> <JudgeLastName>Carpenter</JudgeLastName> <JudgeType>Penalty</JudgeType> </JudgeTableEntity> </ArrayOfJudgeTableEntity>
==========================================
Christoph;
The code and XML was included in the post. I went to your web site but did
not find the tutorial you mentioned. Exactly where is it?
Wayne
"Christoph Schittko [MVP]" <IN**********@austin.rr.com> wrote in message
news:ei**************@TK2MSFTNGP12.phx.gbl... Wayne,
It's hard to tell what's going on without seeing code and/or XML. I have a tutorial on serializing and deserializing arrays at [0]. Take a look and feel free to post back if you have additional questions.
HTH, Christoph Schittko MVP XML http://weblogs.asp.net/cschittko
-----Original Message----- From: Wayne Wengert [mailto:wa***************@wengert.com] Posted At: Monday, January 24, 2005 5:25 AM Posted To: microsoft.public.dotnet.xml Conversation: Deserializing an array Subject: Deserializing an array
Using VB.NET I want to read in an XML file that has an array of objects and then step through the resulting array in code. I build a class to define the structure and I am running code to read in the data but I can't figure out where the data is in the resulting array. Most of the relevant code is below. When I run the code to desrialize I get no errors but if I try to look at some of the data via the command window I get errors such as this: ?judges2.Judges(0).JudgeFirstName
Index '0' for dimension '0' is out of range. What am I missing here? Wayne ================= Execution Code =======================
Private Sub btnImport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImport.Click
ReadJudgesTable("c:\2005 WGI\WGI Tabulation Program\Data Files\data\JudgesTable.xml")
End Sub
Protected Sub ReadJudgesTable(ByVal filename As String)
Dim ser As New XmlSerializer(GetType(ArrayOfJudgeTableEntity))
' Read In the Judges table
Dim fs2 As New FileStream(filename, FileMode.Open)
' Deserialize into another instance of ArrayOfJudgeTableEntity
Dim judges2 As ArrayOfJudgeTableEntity = CType(ser.Deserialize(fs2), ArrayOfJudgeTableEntity)
fs2.Close()
MsgBox("JudgesTable has been deserialized - I hope", MsgBoxStyle.Exclamation, "Got Judges")
End Sub
================================================== ==
================== Class Definition ==================
Imports System.Xml
Imports System.Xml.Serialization
Imports System.Collections
Public Class ArrayOfJudgeTableEntity
<XmlArray("JudgeTableEntity"), XmlArrayItem("Judge",
IsNullable:=True)> _ Public Judges() As Judge
Public Sub New()
End Sub 'New
'Public Sub New(ByVal id As String, ByVal fn As String, ByVal ln As String, ByVal type As String)
' JudgeID = id
' JudgeFirstName = fn
' JudgeFirstName = ln
' JudgeType = type
'End Sub 'New
End Class 'ArrayOfJudgeTableEntity
Public Class Judge
Public JudgeID As String
Public JudgeFirstName As String
Public JudgeLastName As String
Public JudgeType As String
Public Sub New()
End Sub 'New
Public Sub New(ByVal id As String, ByVal fn As String, ByVal ln As
String, ByVal type As String)
JudgeID = id
JudgeType = type
JudgeFirstName = fn
JudgeLastName = ln
End Sub 'New
End Class 'Judge
==================================== =========== Sample XML Data ================
<?xml version="1.0" encoding="utf-8"?> <ArrayOfJudgeTableEntity xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <JudgeTableEntity> <JudgeId>63371991-cdf9-4cc5-99c1-a42c599498f8</JudgeId> <JudgeFirstName>Kristen</JudgeFirstName> <JudgeLastName>O'Melia</JudgeLastName> <JudgeType>Equipment</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>ce2c0c6e-4094-43da-9d8c-9726d81b017e</JudgeId> <JudgeFirstName>Smith</JudgeFirstName> <JudgeLastName>Dan</JudgeLastName> <JudgeType>Movement</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>efe977f6-04ec-4a65-ae46-34b0f75de87f</JudgeId> <JudgeFirstName>Kathy</JudgeFirstName> <JudgeLastName>Whitcomb</JudgeLastName> <JudgeType>Ensemble Color Guard</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>99d92f77-39e1-46b8-b9e2-446b8cea1b0c</JudgeId> <JudgeFirstName>Shirlee</JudgeFirstName> <JudgeLastName>Whitcomb</JudgeLastName> <JudgeType>General Effect Color Guard</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>f7ae92ef-9bb2-48fe-bbe8-3c566b924d0f</JudgeId> <JudgeFirstName>George</JudgeFirstName> <JudgeLastName>Oliviero</JudgeLastName> <JudgeType>General Effect Color Guard</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>5e1cad18-4ef9-4625-99c2-ee12c2b05cda</JudgeId> <JudgeFirstName>Lee</JudgeFirstName> <JudgeLastName>Carpenter</JudgeLastName> <JudgeType>Penalty</JudgeType> </JudgeTableEntity> </ArrayOfJudgeTableEntity>
==========================================
I'm sorry, I didn't scroll down far enough last night to find the XML
AND I didn't paste the link ... bad christoph
The link I meant to include was: http://www.topxml.com/xmlserializer/...on_classes.asp.
Looking at your classes though, this class definition would match
<XmlArray("JudgeTableEntity"), XmlArrayItem("Judge", IsNullable:=True)>
_
Public Judges() As Judge
This XML:
<JudgeTableEntity>
<Judge>
....
</Judge>
<Judge>
....
</Judge>
</JudgeTableEntity>
Because you declare the class to map to XML with an enclosing XmlArray
item <JudgeTableEntity> for array item elements <Judge>.
In the example XML you posted though, there is no enclosing element
around the array items. Instead, the array items are JudgeTableEntity
elements.
Change the class definition to:
<XmlElement("JudgeTableEntity", IsNullable:=True)> _
Public Judges() As Judge
And you should be good to go.
HTH,
Christoph Schittko
MVP XML http://weblogs.asp.net/cschittko -----Original Message----- From: Wayne Wengert [mailto:wa***************@wengert.com] Posted At: Wednesday, January 26, 2005 3:28 PM Posted To: microsoft.public.dotnet.xml Conversation: Deserializing an array Subject: Re: Deserializing an array
Christoph;
The code and XML was included in the post. I went to your web site but
did not find the tutorial you mentioned. Exactly where is it?
Wayne
"Christoph Schittko [MVP]" <IN**********@austin.rr.com> wrote in
message news:ei**************@TK2MSFTNGP12.phx.gbl... Wayne,
It's hard to tell what's going on without seeing code and/or XML. I
have a tutorial on serializing and deserializing arrays at [0]. Take a
look and feel free to post back if you have additional questions.
HTH, Christoph Schittko MVP XML http://weblogs.asp.net/cschittko
-----Original Message----- From: Wayne Wengert [mailto:wa***************@wengert.com] Posted At: Monday, January 24, 2005 5:25 AM Posted To: microsoft.public.dotnet.xml Conversation: Deserializing an array Subject: Deserializing an array
Using VB.NET I want to read in an XML file that has an array of objects and then step through the resulting array in code. I build a class to define the structure and I am running code to read in the data but I can't
figure out where the data is in the resulting array. Most of the relevant
code is below. When I run the code to desrialize I get no errors but if I
try to look at some of the data via the command window I get errors such
as this: ?judges2.Judges(0).JudgeFirstName
Index '0' for dimension '0' is out of range. What am I missing here? Wayne ================= Execution Code =======================
Private Sub btnImport_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnImport.Click
ReadJudgesTable("c:\2005 WGI\WGI Tabulation Program\Data Files\data\JudgesTable.xml")
End Sub
Protected Sub ReadJudgesTable(ByVal filename As String)
Dim ser As New XmlSerializer(GetType(ArrayOfJudgeTableEntity))
' Read In the Judges table
Dim fs2 As New FileStream(filename, FileMode.Open)
' Deserialize into another instance of ArrayOfJudgeTableEntity
Dim judges2 As ArrayOfJudgeTableEntity =
CType(ser.Deserialize(fs2), ArrayOfJudgeTableEntity)
fs2.Close()
MsgBox("JudgesTable has been deserialized - I hope", MsgBoxStyle.Exclamation, "Got Judges")
End Sub
================================================== ==
================== Class Definition ==================
Imports System.Xml
Imports System.Xml.Serialization
Imports System.Collections
Public Class ArrayOfJudgeTableEntity
<XmlArray("JudgeTableEntity"), XmlArrayItem("Judge", IsNullable:=True)> _ Public Judges() As Judge
Public Sub New()
End Sub 'New
'Public Sub New(ByVal id As String, ByVal fn As String, ByVal ln
As String, ByVal type As String)
' JudgeID = id
' JudgeFirstName = fn
' JudgeFirstName = ln
' JudgeType = type
'End Sub 'New
End Class 'ArrayOfJudgeTableEntity
Public Class Judge
Public JudgeID As String
Public JudgeFirstName As String
Public JudgeLastName As String
Public JudgeType As String
Public Sub New()
End Sub 'New
Public Sub New(ByVal id As String, ByVal fn As String, ByVal ln As
String, ByVal type As String)
JudgeID = id
JudgeType = type
JudgeFirstName = fn
JudgeLastName = ln
End Sub 'New
End Class 'Judge
==================================== =========== Sample XML Data ================
<?xml version="1.0" encoding="utf-8"?> <ArrayOfJudgeTableEntity
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <JudgeTableEntity> <JudgeId>63371991-cdf9-4cc5-99c1-a42c599498f8</JudgeId> <JudgeFirstName>Kristen</JudgeFirstName> <JudgeLastName>O'Melia</JudgeLastName> <JudgeType>Equipment</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>ce2c0c6e-4094-43da-9d8c-9726d81b017e</JudgeId> <JudgeFirstName>Smith</JudgeFirstName> <JudgeLastName>Dan</JudgeLastName> <JudgeType>Movement</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>efe977f6-04ec-4a65-ae46-34b0f75de87f</JudgeId> <JudgeFirstName>Kathy</JudgeFirstName> <JudgeLastName>Whitcomb</JudgeLastName> <JudgeType>Ensemble Color Guard</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>99d92f77-39e1-46b8-b9e2-446b8cea1b0c</JudgeId> <JudgeFirstName>Shirlee</JudgeFirstName> <JudgeLastName>Whitcomb</JudgeLastName> <JudgeType>General Effect Color Guard</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>f7ae92ef-9bb2-48fe-bbe8-3c566b924d0f</JudgeId> <JudgeFirstName>George</JudgeFirstName> <JudgeLastName>Oliviero</JudgeLastName> <JudgeType>General Effect Color Guard</JudgeType> </JudgeTableEntity> <JudgeTableEntity> <JudgeId>5e1cad18-4ef9-4625-99c2-ee12c2b05cda</JudgeId> <JudgeFirstName>Lee</JudgeFirstName> <JudgeLastName>Carpenter</JudgeLastName> <JudgeType>Penalty</JudgeType> </JudgeTableEntity> </ArrayOfJudgeTableEntity>
==========================================
Christoph;
Thanks for that link - looks like a lot of good resources
As for my project, I found that my approach was giving an extra layer of
arrays - I am trying to work that out now. May be back for more help.
Wayne
"Christoph Schittko [MVP]" <IN**********@austin.rr.com> wrote in message
news:uF*************@TK2MSFTNGP15.phx.gbl... I'm sorry, I didn't scroll down far enough last night to find the XML AND I didn't paste the link ... bad christoph
The link I meant to include was:
http://www.topxml.com/xmlserializer/...on_classes.asp.
Looking at your classes though, this class definition would match
<XmlArray("JudgeTableEntity"), XmlArrayItem("Judge", IsNullable:=True)> _
Public Judges() As Judge
This XML:
<JudgeTableEntity> <Judge> ... </Judge> <Judge> ... </Judge> </JudgeTableEntity>
Because you declare the class to map to XML with an enclosing XmlArray item <JudgeTableEntity> for array item elements <Judge>.
In the example XML you posted though, there is no enclosing element around the array items. Instead, the array items are JudgeTableEntity elements.
Change the class definition to:
<XmlElement("JudgeTableEntity", IsNullable:=True)> _ Public Judges() As Judge
And you should be good to go.
HTH, Christoph Schittko MVP XML http://weblogs.asp.net/cschittko
-----Original Message----- From: Wayne Wengert [mailto:wa***************@wengert.com] Posted At: Wednesday, January 26, 2005 3:28 PM Posted To: microsoft.public.dotnet.xml Conversation: Deserializing an array Subject: Re: Deserializing an array
Christoph;
The code and XML was included in the post. I went to your web site but did not find the tutorial you mentioned. Exactly where is it?
Wayne
"Christoph Schittko [MVP]" <IN**********@austin.rr.com> wrote in message news:ei**************@TK2MSFTNGP12.phx.gbl... Wayne,
It's hard to tell what's going on without seeing code and/or XML. I have a tutorial on serializing and deserializing arrays at [0]. Take a look and feel free to post back if you have additional questions.
HTH, Christoph Schittko MVP XML http://weblogs.asp.net/cschittko
> -----Original Message----- > From: Wayne Wengert [mailto:wa***************@wengert.com] > Posted At: Monday, January 24, 2005 5:25 AM > Posted To: microsoft.public.dotnet.xml > Conversation: Deserializing an array > Subject: Deserializing an array > > Using VB.NET I want to read in an XML file that has an array of objects > and > then step through the resulting array in code. I build a class to define > the > structure and I am running code to read in the data but I can't figure out > where the data is in the resulting array. Most of the relevant code is > below. When I run the code to desrialize I get no errors but if I try to > look at some of the data via the command window I get errors such as this: > > ?judges2.Judges(0).JudgeFirstName > > Index '0' for dimension '0' is out of range. > > > > What am I missing here? > > > > Wayne > > > > ================= Execution Code ======================= > > Private Sub btnImport_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles btnImport.Click > > ReadJudgesTable("c:\2005 WGI\WGI Tabulation Program\Data > Files\data\JudgesTable.xml") > > End Sub > > Protected Sub ReadJudgesTable(ByVal filename As String) > > Dim ser As New XmlSerializer(GetType(ArrayOfJudgeTableEntity)) > > ' Read In the Judges table > > Dim fs2 As New FileStream(filename, FileMode.Open) > > ' Deserialize into another instance of ArrayOfJudgeTableEntity > > Dim judges2 As ArrayOfJudgeTableEntity = CType(ser.Deserialize(fs2), > ArrayOfJudgeTableEntity) > > fs2.Close() > > MsgBox("JudgesTable has been deserialized - I hope", > MsgBoxStyle.Exclamation, "Got Judges") > > End Sub > > ================================================== == > > ================== Class Definition ================== > > Imports System.Xml > > Imports System.Xml.Serialization > > Imports System.Collections > > Public Class ArrayOfJudgeTableEntity > > <XmlArray("JudgeTableEntity"), XmlArrayItem("Judge", IsNullable:=True)> _ > > Public Judges() As Judge > > > Public Sub New() > > End Sub 'New > > 'Public Sub New(ByVal id As String, ByVal fn As String, ByVal ln As > String, > ByVal type As String) > > ' JudgeID = id > > ' JudgeFirstName = fn > > ' JudgeFirstName = ln > > ' JudgeType = type > > 'End Sub 'New > > End Class 'ArrayOfJudgeTableEntity > > Public Class Judge > > Public JudgeID As String > > Public JudgeFirstName As String > > Public JudgeLastName As String > > Public JudgeType As String > > Public Sub New() > > End Sub 'New > > Public Sub New(ByVal id As String, ByVal fn As String, ByVal ln As String, > ByVal type As String) > > JudgeID = id > > JudgeType = type > > JudgeFirstName = fn > > JudgeLastName = ln > > End Sub 'New > > End Class 'Judge > > ==================================== > > > > =========== Sample XML Data ================ > > <?xml version="1.0" encoding="utf-8"?> > <ArrayOfJudgeTableEntity xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > <JudgeTableEntity> > <JudgeId>63371991-cdf9-4cc5-99c1-a42c599498f8</JudgeId> > <JudgeFirstName>Kristen</JudgeFirstName> > <JudgeLastName>O'Melia</JudgeLastName> > <JudgeType>Equipment</JudgeType> > </JudgeTableEntity> > <JudgeTableEntity> > <JudgeId>ce2c0c6e-4094-43da-9d8c-9726d81b017e</JudgeId> > <JudgeFirstName>Smith</JudgeFirstName> > <JudgeLastName>Dan</JudgeLastName> > <JudgeType>Movement</JudgeType> > </JudgeTableEntity> > <JudgeTableEntity> > <JudgeId>efe977f6-04ec-4a65-ae46-34b0f75de87f</JudgeId> > <JudgeFirstName>Kathy</JudgeFirstName> > <JudgeLastName>Whitcomb</JudgeLastName> > <JudgeType>Ensemble Color Guard</JudgeType> > </JudgeTableEntity> > <JudgeTableEntity> > <JudgeId>99d92f77-39e1-46b8-b9e2-446b8cea1b0c</JudgeId> > <JudgeFirstName>Shirlee</JudgeFirstName> > <JudgeLastName>Whitcomb</JudgeLastName> > <JudgeType>General Effect Color Guard</JudgeType> > </JudgeTableEntity> > <JudgeTableEntity> > <JudgeId>f7ae92ef-9bb2-48fe-bbe8-3c566b924d0f</JudgeId> > <JudgeFirstName>George</JudgeFirstName> > <JudgeLastName>Oliviero</JudgeLastName> > <JudgeType>General Effect Color Guard</JudgeType> > </JudgeTableEntity> > <JudgeTableEntity> > <JudgeId>5e1cad18-4ef9-4625-99c2-ee12c2b05cda</JudgeId> > <JudgeFirstName>Lee</JudgeFirstName> > <JudgeLastName>Carpenter</JudgeLastName> > <JudgeType>Penalty</JudgeType> > </JudgeTableEntity> > </ArrayOfJudgeTableEntity> > > ==========================================
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Justin Armstrong |
last post by:
I'm having difficulties deserializing some objects.
Consider the following example of what I'm trying to do:
----------------------------------------------------------
class Person
{
string...
|
by: Artur Niesporek |
last post by:
Hi guys,
when receiving a soap response posted back from a server i get the
following error when deserializing the soap message. The problem seems
to be with the item-collection of the...
|
by: Casey |
last post by:
So I'm using XmlSerializer to serialize out a wrapper object that
contains an arbitrary number of other objects. The class definitions
listed below are made to be very generic. Some of the...
|
by: Earl Teigrob |
last post by:
I am saving and restoring value types such as Int32, DateTime and Boolean in
strings. I was wondering if there is a mechanism build into .NET for
serializing and deserializing these to string...
|
by: Kevin R |
last post by:
Hi All,
I have a binary file, the first few k of which contains some
information which I need to stick in to an array of types,let's call
them Wongas.
Each Wonga is made up of two ulongs and a...
|
by: ce |
last post by:
Being a newbie regarding serialization and memorystreams, I was trying to
see if i could improve page performance (avoiding going to the db on a
postback) by saving my serialized business object in...
|
by: GAURAV KRISHNA |
last post by:
I am able to deserialize an array using XMLSerializer but the size of an
array is 0.The problem seems to be because of unqualified element name but I
am not very sure.
Here is what I did:
I...
|
by: Sivajee Akula |
last post by:
Hello All,
I am trying to consume a .NET Service from Adobe LiveCycle Workflow. The service deals with complex objects. I am getting the following exception at the time of invocation of the...
|
by: Chris |
last post by:
I need to serialise a business object into a session as a string. The reason
for this is that we have to run session state with classic ASP and the code
we use in effect mean ASP.net sessions can...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
|
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...
| |