XML Serialization With Custom Namespace Attributes

by John 27. April 2011 05:16

So, after a bit research, I discovered that my brain wasn't working well.  It completely passed me by that the prefix for the attribute names was actually a namespace. With that, I was able to modifiy the property declaration and there's my namespace-prefixed attributes!

<System.Xml.Serialization.XmlAttributeAttribute([AttributeName]:="file", Namespace:="bb", Form:=System.Xml.Schema.XmlSchemaForm.Qualified)> _
Public Property file() As String
        Get
                Return Me.fileField
        End Get
        Set(ByVal value As String)
                Me.fileField = value
        End Set
End Property

Which produced the XML:

<resource xml:base="RSRC4" bb:file="RSRC4.dat" bb:title="New Item" identifier="RSRC4" type="bb-x-doc"  />

Tags: , ,

VB

Comments are closed

About Me

I'm a .Net developer in St. Louis, MO working for Ferguson Consulting. 

Professional Info

Tag cloud