在.Net中操作xml文档,给节点添加,xsi:noNamespaceSchemaLocation属性时,不可以使用
XmlElement eleRoot = doc.CreateElement("DataList");
eleRoot.SetAttribute("xsi:noNamespaceSchemaLocation", "兽药产品入库数据_其他企业1.1.xsd");
这样的使用结果,是
<noNamespaceSchemaLocation="兽药产品入库数据_其他企业1.1.xsd"/>
缺少了"xsi:",
需要使用
XmlElement eleRoot = doc.CreateElement("DataList");
XmlAttribute xsispace = doc.CreateAttribute("xsi", "noNamespaceSchemaLocation", "http://www.w3.org/2001/XMLSchema-instance");
xsispace.Value = "兽药产品入库数据_其他企业1.1.xsd";
eleRoot.Attributes.Append(xsispace);
这样的使用结果,才是
<xsi:noNamespaceSchemaLocation="兽药产品入库数据_其他企业1.1.xsd"/>
本文详细介绍了在.Net环境下如何正确为XML元素添加xsi:noNamespaceSchemaLocation属性,避免常见错误并确保XML文档符合W3C标准。
21万+

被折叠的 条评论
为什么被折叠?



