| re: XmlDocument xsi: Problem
Hi Mark,
First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to create a root node like
<TestCase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="TestCaseSchema_03.x sd">. If there is any
misunderstanding, please feel free to let me know.
In this case, we can first create an attribute node using
XmlDocument.CreateAttribute() and then add it to the element using
XmlElement.SetAttributeNode() method. Here I wrote some sample code. HTH.
XmlDocument doc = new XmlDocument();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
XmlElement ele = doc.CreateElement("TestCase");
XmlAttribute att = doc.CreateAttribute("xsi", "noNamespaceSchemaLocation",
"http://www.w3.org/2001/XMLSchema-instance");
att.Value = "TestCaseSchema_03.xsd";
ele.SetAttributeNode(att);
doc.AppendChild(ele);
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights." |