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")

1 Answer 1

6

Try changing your attributes thus:

<System.Xml.Serialization.XmlAttribute("rmName",
    Namespace:="http://www.example.com",
    Form := XmlSchemaForm.Qualified)>
Sign up to request clarification or add additional context in comments.

1 Comment

Great ! <System.Xml.Serialization.XmlAttribute("building", Form:=System.Xml.Schema.XmlSchemaForm.Qualified, Namespace:="example.com")> _

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.