2013-08-05 64 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