How can I create this xml header ?

  • Thread starter Thread starter AlanChong
  • Start date Start date
A

AlanChong

Guest
Hi all. How can I create the following xml header ?

<HEADER xmlns:xsd="XML Schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

I use the following code to create xml for another purpose.

XmlDocument doc = new XmlDocument();
XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "utf-8", null);
XmlElement root = doc.DocumentElement;
doc.InsertBefore(xmlDeclaration, root);

XmlElement RootNode = doc.CreateElement("HEADER", NameSpace);
XmlAttribute schemaLocation = doc.CreateAttribute("xsi", "schemaLocation",
"http://www.w3.org/2001/XMLSchema-instance");
schemaLocation.Value = "urn:wco:datamodel:TW:NX601:R-04-00 NX601.xsd";
RootNode.SetAttributeNode(schemaLocation);

doc.AppendChild(RootNode);

Resulting header as follow :

<HEADER xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:wco:datamodel:TW:NX601:R-04-00 NX601.xsd">

No LINQ ,please. I want to use code similar to the above. Thanks.

Continue reading...
 
Back
Top