Results 1 to 2 of 2

Thread: [RESOLVED] Serialization

  1. #1

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Resolved [RESOLVED] Serialization

    Hi guys

    I am trying to create a SAFT file
    http://www.oecd.org/ctp/taxadministr...quirements.htm

    I have the following class

    Code:
    Imports System.ComponentModel
    
    <TypeConverter(GetType(ExpandableObjectConverter))> _
    Public Class Header
    
        Private _companyAddress As List(Of CompanyAddress)
    
        Public Property AuditFileVersion As String
        Public Property CompanyID As String
        Public Property TaxRegistrationNumber As String
    
        Public Property CompanyAddress() As List(Of CompanyAddress)
            Get
                Return _companyAddress
            End Get
            Set(ByVal value As List(Of CompanyAddress))
                _companyAddress = value
            End Set
        End Property
    
        Public Sub New()
            _companyAddress = New List(Of CompanyAddress)
        End Sub
    
    End Class
    
    Public Class CompanyAddress
    
        Public Property AddressDetail As String
        Public Property City As String
        Public Property PostalCode As String
        Public Property Country As String
    
    End Class
    when i serialize the object i get

    Code:
    <Header>
      <AuditFileVersion>1.1.0</AuditFileVersion>
      <CompanyAddress>
        <CompanyAddress>
          <City>Porto</City>
          <PostalCode>4100</PostalCode>
        </CompanyAddress>
        <CompanyAddress>
          <City>Porto</City>
          <PostalCode>4100</PostalCode>
        </CompanyAddress>
        <CompanyAddress>
          <City>Porto</City>
          <PostalCode>4100</PostalCode>
        </CompanyAddress>
      </CompanyAddress>
    </Header>
    as you can see i get <CompanyAddress> element repeated...

    The result i want to produce is something like this:

    Code:
    <Header>
      <AuditFileVersion>1.1.0</AuditFileVersion>
        <CompanyAddress>
          <City>Porto</City>
          <PostalCode>4100</PostalCode>
        </CompanyAddress>
        <CompanyAddress>
          <City>Porto</City>
          <PostalCode>4100</PostalCode>
        </CompanyAddress>
        <CompanyAddress>
          <City>Porto</City>
          <PostalCode>4100</PostalCode>
        </CompanyAddress>
    </Header>
    with only one element created for each item (CompanyAddress)

    Any help ?
    Help keep this forum clean: Remember to mark your thread as resolved · Search before you post · Remember to rate posts that help

    VS2010: Visual Studio 2010 Keybinding Posters
    · Service Pack 1
    Tools: GhostDoc - automatically generates XML documentation comments
    · NuGet package Manager · PowerCommands IDE extensions
    Source Control: ankhsvn - integration for SVN
    · Windows Shell Extension for Subversion

    Development Laptop: Intel Core i5 430M 2.26 GHz @ 2.53 GHz
    · 4096 MB, DDR3 PC3-8500F (533 MHz), Kingston · ATI Mobility Radeon HD 5470 · 15.6 @ 16:9, 1366x768 pixel, HD LED LCD

    I follow:
    JoelOnSoftware - A weblog by Joel Spolsky, a programmer working in New York City, about software and software companies
    ScottGu's Blog - Scott Guthrie works for Microsoft as the Product Manager of the .NET Framework
    Portugal-a-Programar - Portuguese Developers Community
    .NET Rocks! - is a weekly Internet audio talk show for .NET Developers.

    Programming Languages:
    C#
    · VB.NET · JAVA · PHP · Javascript
    Other:
    XML
    · HTML · CSS · JQuery · SQL



    *** Proudly Portuguese ***

  2. #2

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Re: Serialization

    resolved

    Code:
    Imports System.ComponentModel
    
    <TypeConverter(GetType(ExpandableObjectConverter))> _
    Public Class Header
    
        Private _companyAddress As List(Of CompanyAddress)
    
        Public Property AuditFileVersion As String
        Public Property CompanyID As String
        Public Property TaxRegistrationNumber As String
    
        <System.Xml.Serialization.XmlElement("CompanyAddress")> _
        Public Property CompanyAddress() As List(Of CompanyAddress)
            Get
                Return _companyAddress
            End Get
            Set(ByVal value As List(Of CompanyAddress))
                _companyAddress = value
            End Set
        End Property
    
        Public Sub New()
            _companyAddress = New List(Of CompanyAddress)
        End Sub
    
    End Class
    Help keep this forum clean: Remember to mark your thread as resolved · Search before you post · Remember to rate posts that help

    VS2010: Visual Studio 2010 Keybinding Posters
    · Service Pack 1
    Tools: GhostDoc - automatically generates XML documentation comments
    · NuGet package Manager · PowerCommands IDE extensions
    Source Control: ankhsvn - integration for SVN
    · Windows Shell Extension for Subversion

    Development Laptop: Intel Core i5 430M 2.26 GHz @ 2.53 GHz
    · 4096 MB, DDR3 PC3-8500F (533 MHz), Kingston · ATI Mobility Radeon HD 5470 · 15.6 @ 16:9, 1366x768 pixel, HD LED LCD

    I follow:
    JoelOnSoftware - A weblog by Joel Spolsky, a programmer working in New York City, about software and software companies
    ScottGu's Blog - Scott Guthrie works for Microsoft as the Product Manager of the .NET Framework
    Portugal-a-Programar - Portuguese Developers Community
    .NET Rocks! - is a weekly Internet audio talk show for .NET Developers.

    Programming Languages:
    C#
    · VB.NET · JAVA · PHP · Javascript
    Other:
    XML
    · HTML · CSS · JQuery · SQL



    *** Proudly Portuguese ***

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