大家好我正在創建一個應用程序來動態生成XML
文件。在此我想將schemalocation
和XSI
添加到XML
Root
我該怎麼做。我想補充以下如何將Schema位置和XSI動態添加到XML文件
xmlns="http://www.irs.gov/efile"
xsi:SchemaLocation="http://www.irs.goc/efile ReturnData941.xsd"
和
xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
這是我的樣品已動態生成
XmlDocument doc = new XmlDocument();
XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
doc.AppendChild(docNode);
XmlNode returnData = doc.CreateElement("ReturnData");
XmlAttribute documnetCount = doc.CreateAttribute("documentCount"); // after this i would like to add that schema
returnData.Attributes.Append(documnetCount);
所以,我應該得到XML
代碼我XML
如下
<?xml version="1.0" encoding="UTF-8"?>
<ReturnData documentCount="" xsi:SchemaLocation="http://www.irs.goc/efile ReturnData941.xsd" xmlns="http://www.irs.gov/efile" xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance" />
謝謝斯科特它的工作原理 – Dotnet 2011-12-16 08:21:40