noNamespaceSchemaLocation前添加xsi

在.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"/>

posted @ 2015-10-08 12:33  獠牙  阅读(2021)  评论(0编辑  收藏  举报