我必须在C#中创建一个XML文档.
根元素必须如下所示:
<valuation-request
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="valuations.xsd">
Run Code Online (Sandbox Code Playgroud)
我正在使用以下内容
XmlElement root = X.CreateElement("valuation-request");
root.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
root.SetAttribute("xsi:noNamespaceSchemaLocation", "valuations.xsd");
Run Code Online (Sandbox Code Playgroud)
然而这产生了
<valuation-request
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
noNamespaceSchemaLocation="valuations.xsd"> //missing the xsi:
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
使用SetAttribute的重载,它也接受名称空间:
root.SetAttribute("noNamespaceSchemaLocation",
"http://www.w3.org/2001/XMLSchema-instance",
"valuations.xsd"
);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7380 次 |
最近记录: |