2nd line - “xmlmns=” is on the right side and inside the quotes and shouldn’t be there.
I’m can’t get the 5th line - xmlns:n1=“urn:us:gov:treasury:irs:msg:form1094-1095Btransmitterupstreammessage” - to print even though I’m setting the attribute to include it.
I hope someone out there understands this better than I do and will chime in.
A couple of things I noticed while playing around…first, you can get rid of the extra “xmlns=” in line 2 if you change your CreateElement line to:
XmlDoc.AppendChild XmlDoc.CreateElement(“urn:us:gov:treasury:irs:common”,“n1:Form109495BTransmittalUpstream”)
But this (and your code) is making line 2 “xmlns:n1” instead of just “xmlns”. I don’t do namespace stuff, but you shouldn’t have just plain “xmlns”, right? Then later on for line 5 you’re trying to set xmlns:n1 again, right? If you change one of those "n1"s to something else, they both print, so they don’t like competing with each other.
I don’t see a way to change the order - I tried removing the xmlns:n1 attribute node so I could add it later, but it won’t let me (I get an exception). I assume it’s because it is protecting you from doing something silly like removing it and forgetting to put it back.
So if you HAVE to have it in the order you want, I’d probably generate it as is, get the string, manipulate the order, then save it that way. Kind of a pain though.
Update - For now, I’m not worried about the order of the namespace specification in the root node, but the rest of the XML file is generating just perfect so I think I’m good for now. Thanks for all the replies.
If I find that the order matters in the root node, I will try Bill’s suggestion of just editing the XML code as a text file.
This is for an xml document that will be submitted to the IRS and we don’t have any live XML file testing available yet, but that will happen this fall.