Does the order of xmlns elements matter

断了今生、忘了曾经 提交于 2019-12-23 08:47:39

问题


I'm not sure how to search google for this but does the matter of the xmlns elements matter in an XML File? I'm creating a XML file using XMLWriter in ASP.NET(VB) and I'm trying to match an example I was provided.

<ns2:SubmitSMReq xmlns:ns4="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns3="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-6-MM7-1-4" xmlns:ns2="http://somesite/schema">

This is what I have in my vb file:

writer.WriteStartElement("ns2", "SubmitSMReq", "http://schemas.xmlsoap.org/soap/envelope/")
writer.WriteAttributeString("xmlns", "ns3", Nothing, "http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-6-MM7-1-4")
writer.WriteAttributeString("xmlns", "ns4", Nothing, "http://somesite/schema")

But it generates the XML differently.

<ns2:SubmitSMReq xmlns:ns3="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-6-MM7-1-4" xmlns:ns4="http://somesite/schema" xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/">

I realize the xmlns in the provided example has different "ns" (namespace?)" numbers. Does either of these things matter? Should I be alright with my file?

Thanks


回答1:


According to the current version of the XML specification,

the order of attribute specifications in a start-tag or empty-element tag is not significant.

So no, it shouldn't matter, assuming that the system which eventually reads your XML is compliant.



来源:https://stackoverflow.com/questions/18067491/does-the-order-of-xmlns-elements-matter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!