大家好我正在创建一个应用程序来动态生成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