Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > .NET

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 10-23-2009, 11:02 AM
luckyjack luckyjack is offline
Registered User
 
Join Date: Dec 2008
Posts: 4
Thumbs up Problem with XML Serialzation of Collection of String

Hello,
I am using the XML Serializer to create an XML Schema. In one part of the XML, I have an element called 'parameters', which returns a collection of strings that should be called 'parameter'. The output is supposed to look like this:

Code:
<parameters>
    <parameter>Value 1</parameter>
    <parameter>Value 2</parameter>
    <parameter>Value 3</parameter>
</parameters>
It's coming out like this:

Code:
<parameters>
    <string>Value 1</string>
    <string>Value 2</string>
    <string>Value 3</string>
</parameters>
This is my code for the collection:

Code:
Public Class ParameterCollection
    Inherits System.Collections.ObjectModel.Collection(Of String)

    Public Sub New()
        MyBase.New()
    End Sub
    <Xml.Serialization.XmlArrayItem("parameter")> _
    <Xml.Serialization.XmlElement("parameter")> _
    Default Public Overloads Property Item(ByVal index As Integer) As String
        Get
            Return MyBase.Item(index)
        End Get
        Set(ByVal value As String)
            If index <= Me.Count - 1 Then
                Me.Item(index) = value
            Else
                Throw New IndexOutOfRangeException()
            End If
        End Set
    End Property
End Class
I need the output to look exactly like my example at the top - I can't use an attribute, nor a subclass called 'parameter'. The output does not come out right (at least from what I've tried). I tried using different combinations of xmlserializer directives, and I've tried an ArrayList in addition to the collection all with the same results. It seems as if the serializer is ignoring my directive
to call the element a 'parameter' and just calling it 'string'.

I hope someone can help!
Paul
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
string array in c++ emeric C++ 11 07-16-2007 10:36 PM
Submitting Infopath to a .net Web Service athomas42 .NET 1 06-25-2007 05:54 PM
Input string was not in a correct format mdengler ASP.NET 0 11-26-2002 03:32 PM
Need Help debugging errors form these programs number1! Fred Mayes Java 1 06-05-2001 07:12 AM
Problem Converting ADO Recordset to XML CHRISTOS STAVRINOU VB Classic 0 11-16-2000 05:58 PM


All times are GMT -4. The time now is 01:18 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.