问题描述
以下是我想要实现的格式。
<?xml version="1.0" ?>
<eExact xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="eExact-Schema.xsd">
这是我到目前为止的代码,缺少 xsi
var doc = new XmlDocument();
XmlNode docNode = doc.CreateXmlDeclaration("1.0",null,null);
doc.AppendChild(docNode);
XmlNode rootNode = doc.CreateElement("eExact");
doc.AppendChild(rootNode);
XmlElement element = doc.DocumentElement;
element.SetAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
element.SetAttribute("noNamespaceSchemaLocation","eExact-Schema.xsd");
下面是我从这段代码中得到的 xml 结果:
<?xml version="1.0"?>
<eExact xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" noNamespaceSchemaLocation="eExact-Schema.xsd">
非常感谢您的帮助。