下面是我想要实现的格式。
<?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">提前感谢你的帮助。
发布于 2021-01-29 22:44:20
https://stackoverflow.com/questions/65917259
复制相似问题