8

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

pnuts
  • 58,317
  • 11
  • 87
  • 139
gm77
  • 113
  • 1
  • 6
  • I'm not sure I understand the problem - the generated XML is what you told the program to generate (you use ns3 and then ns4). If you want it to match the example, switch the order of the ns3 and ns4 lines. – Tim Aug 05 '13 at 20:55
  • 1
    You ever just have one of those Mondays? I changed it to: 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") and it looks perfectly – gm77 Aug 05 '13 at 21:02
  • Yep - I'm having one of them myself today (but not with code) :) – Tim Aug 05 '13 at 21:03
  • Well I hope your day gets better as well. Thanks again – gm77 Aug 05 '13 at 21:05

1 Answers1

9

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.

Polly Shaw
  • 2,932
  • 1
  • 15
  • 21