2

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")> _
    Public Rooms As New System.Collections.Generic.List(Of cRoom)


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


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


End Class

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

Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442

1 Answers1

6

Try changing your attributes thus:

<System.Xml.Serialization.XmlAttribute("rmName",
    Namespace:="http://www.example.com",
    Form := XmlSchemaForm.Qualified)>
David M
  • 71,481
  • 13
  • 158
  • 186