How do you enable xsi:type generation when serializing a class?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bishop

    #1

    How do you enable xsi:type generation when serializing a class?

    I have a location-list class which serializes to:

    <?xml version="1.0" encoding="utf-16"?>
    <location-list xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
    ...
    </location-list>

    but I want to include the xsi:type in the location-list node:

    <?xml version="1.0" encoding="utf-16"?>
    <location-list xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http ://www.w3.org/2001/XMLSchema" xsi:type="locat ion-list">

    Would I do this at the class defintion?

    <System.Seriali zableAttribute( ), _
    System.Xml.Seri alization.XmlTy peAttribute("lo cation-list",
    [Namespace]:="my-service-URI")> _
    Partial Public Class LocationList
    ....
    End Class

    or at the serializer?

    Dim loclist As New LocationList
    Dim xmls As New System.Xml.Seri alization.XmlSe rializer(loclis t.GetType)

    Thanks

Working...