开发者

XML namespace for attributes

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", Namesp开发者_运维百科ace:="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")


Try changing your attributes thus:

<System.Xml.Serialization.XmlAttribute("rmName",
    Namespace:="http://www.example.com",
    Form := XmlSchemaForm.Qualified)>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜