views:

46

answers:

1

Question: I have an xml element + attributes, which all need to be in a namespace. I set the element + all attributes into the namespace oai, and I get:

<oai:room building="AB" rmName="001">

but the XML i need to generate should look like this:

 <oai:room oai:building="AB" oai:rmName="001">

Why does it remove the oai namespace in the attributes once I set the namespace in the xml element ? Well, I see why, but how do I stop this behaviour, since I need it otherwise?

This is the serialization class I use:

<System.Xml.Serialization.XmlElement(ElementName:="room", Namespace:="http://www.example.com")&gt; _
    Public Rooms As New System.Collections.Generic.List(Of cRoom)


Public Class cRoom
    <System.Xml.Serialization.XmlAttribute("building", Namespace:="http://www.example.com")&gt; _
    Public buildingAs String = ""


    <System.Xml.Serialization.XmlAttribute("rmName", Namespace:="http://www.example.com")&gt; _
    Public rmNameAs String = ""


End Class

(oai:="www.example.com")

+2  A: 

Try changing your attributes thus:

<System.Xml.Serialization.XmlAttribute("rmName",
    Namespace:="http://www.example.com",
    Form := XmlSchemaForm.Qualified)>
David M
Great !<System.Xml.Serialization.XmlAttribute("building", Form:=System.Xml.Schema.XmlSchemaForm.Qualified, Namespace:="http://www.example.com")> _
Quandary