首页 > 学院 > 开发设计 > 正文

noNamespaceSchemaLocation前添加xsi

2019-11-14 13:55:53
字体:
来源:转载
供稿:网友

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


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表