2013-08-05 62 views
5

我不确定如何在此搜索谷歌,但xmlns元素的问题在XML文件中很重要吗? 我在ASP.NET(VB)中使用XMLWriter创建一个XML文件,我试图匹配我提供的一个示例。xmlns元素的顺序是否重要

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

这是我在我的VB文件:

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

但不同的生成XML。

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

我意识到在所提供的示例中的xmlns有不同的“NS”(命名?)”号。请问无论这些事情重要吗?我应该没事跟我的档案?

感谢

+0

我不确定我是否理解这个问题 - 生成的XML是您告诉程序生成的(您使用ns3,然后是ns4)。如果您希望它与示例匹配,请切换ns3和ns4行的顺序。 – Tim

+1

你有过这样的星期一吗?我将它改为: writer.WriteStartElement(“ns2”,“SubmitSMReq”,“http:// somesite/schema”) writer.WriteAttributeString(“xmlns”,“ns4”,Nothing,“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“) 和它看起来很完美 – gm77

+0

是的 - 我今天有一个我自己(但不是代码):) – Tim

回答

6

the current version of the XML specification

属性规范的起始标签或空元素标签的顺序并不显著。

因此,不要紧,假设最终读取XML的系统是兼容的。

+0

谢谢,我会尽快解答我的问题。 – gm77