Click to See Complete Forum and Search --> : Having trouble serializing an array to XML doc. Need Help


irishman
December 21st, 2008, 11:10 PM
I have several arrays that could contain up to 300 items. I am trying to serialize them using a For/Next loop so that I don't have to write out a ton of code. But it's not working. I've included my code below as well as the output. Any help would be appreciated.

I have the standard code in the serializer. Here's the other code.

With SaveFileDialog1
.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"
.FilterIndex = 1
.Title = "Save Template"
End With
If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
templatename = SaveFileDialog1.FileName
' create new address object...
Dim address As New Address
' copy the values from the form into the sjq...
PopulateAddressFromForm(address)
' save the address..
address.Save(templatename)
End If

Public Sub PopulateAddressFromForm(ByVal address As Address)
For questionnumber = 1 To 165
address.questionformat(questionnumber) = questionformat(questionnumber)
address.singleynsc(questionnumber) = singleynsc(questionnumber)
Next
End Sub

I was hoping it would show up in the XML file as:

<questionformat(1)>3</questionformat(1)>
<singleynsc(1)>3</qsingleynsc(1)>

Is this even possible? This is the output it's giving me this:

<questionformat>
<double>0</double>
<double>3</double>
<double>0</double>
<double>0</double>
<double>0</double>......

irishman
December 22nd, 2008, 10:54 AM
I forgot to note that I am using VB.NET 2003