I am trying to make an XML file with a root element:
<urn:Command complete="true" xmlns:urn="namespaceURI">
So I have an element Command
a namespace namespaceURI
a prefix urn
and finally an attribute string with name complete
a value true
and no namespace.
The code I have made to do this returns:
<urn:Command xmlns:urn="namespaceURI" complete="true">
So the problem is I would like the attribute string to be before the namespace definition in the XML file and I can't find a similar problem on this website.
I have tried writing a StartElement
with a prefix and namespace then writing an AttributeString
with no namespace, this returns the root element with the defined namespace first followed by the attribute string.
I have also tried only defining a start element and then two attribute strings but then I can't find a way to write the prefix to the start element.
This is my original code that returns the root element with a namespace definition first the the attribute definition:
`Dim Writer as System.Xml.XmlWriter;
dim writerSettings as System.Xml.XmlWriterSettings;
dim basePath as string;
dim source as string;
dim destination as string;
writerSettings = new System.Xml.XmlWriterSettings();
'writerSettings.ConformanceLevel= false;
'writerSettings.Encoding = new System.Text.UTF8Encoding(false);
writerSettings.OmitXmlDeclaration = false;
basePath = System.IO.Path.Combine("\\wnlcuieb502\WEI\Outbound","RolexSet");
source = System.IO.Path.Combine(basePath,"\\wnlcuieb502\WEI\Outbound","TEST.XML");
Writer = System.Xml.XmlWriter.Create(source,writerSettings);
Writer.WriteStartDocument();
Writer.WriteStartElement("urn","SetPackagingOrder","urn:laetus.com:ws:tts:mes");
Writer.WriteAttributeString("complete",null,"true");
Writer.WriteEndElement();
Writer.WriteEndDocument();
Writer.dispose();
try
destination = System.IO.Path.Combine(basePath,"TEST.XML");
while not System.IO.File.Exists(destination)
System.IO.File.Move(source,destination);
endwhile;
catch
LogError(Me.HierarchicalName + ": Could not move XML file: "+ "TEST.XML" +" from " + source + " to " + destination + ", Error: " + error.Message);
endtry;`