CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2007
    Posts
    51

    Having trouble serializing an array to XML doc. Need Help

    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>......

  2. #2
    Join Date
    Jan 2007
    Posts
    51

    Re: Having trouble serializing an array to XML doc. Need Help

    I forgot to note that I am using VB.NET 2003

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured