Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Issues with prefix in serialization

$
0
0
How do i add prefix to XmlArrayItemAttribute

My input and output xml should look like this
    <TelephoneNumbers xmlns:d5p1="somenamespace">      <d5p1:PersonTelephone>    <d5p1:PersonId>4</d5p1:PersonId>    <d5p1:TelephoneNumber>sample string 5</d5p1:TelephoneNumber>      </d5p1:PersonTelephone>      <d5p1:PersonTelephone>    <d5p1:PersonId>4</d5p1:PersonId>    <d5p1:TelephoneNumber>sample string 5</d5p1:TelephoneNumber>      </d5p1:PersonTelephone>    </TelephoneNumbers>




The class generated looks like this

 
  '''<remarks/>    <System.Xml.Serialization.XmlArrayItemAttribute("PersonTelephone", [Namespace]:="somenamespace", IsNullable:=False)> _    Public Property TelephoneNumbers() As PersonTelephoneCollection    Get    Return Me.telephoneNumbersField    End Get    Set(value As PersonTelephoneCollection)    Me.telephoneNumbersField = value    End Set    End Property        Public Class PersonTelephoneCollection        Inherits System.Collections.CollectionBase        Public Sub New()            MyBase.New()        End Sub            Default Public ReadOnly Property Item(index As Integer) As PersonTelephone            Get                Return DirectCast(Me.InnerList(index), PersonTelephone)            End Get        End Property            Public Sub Insert(index As Integer, value As PersonTelephone)            Me.InnerList.Insert(index, value)        End Sub            Public Function Add(value As PersonTelephone) As Integer            Return (Me.InnerList.Add(value))        End Function            End Class    <System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=True, [Namespace]:="somemnamespace"), _     System.Xml.Serialization.XmlRootAttribute([Namespace]:="somemnamespace", IsNullable:=False)> _    Partial Public Class PersonTelephone    ...



Moved away from default Array to a collection

Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>