当前位置:编程学习 > C#/ASP.NET >>

为xml添加xmlns xsi

--------------------编程问答-------------------- 参数
name
类型:System..::.String

属性的限定名。如果名称包含冒号,则 Prefix 属性反映名称中第一个冒号之前的部分,LocalName 属性反映名称中第一个冒号之后的部分。NamespaceURI 保持为空,除非该前缀是一个可识别的内置前缀,例如 xmlns。在这种情况下,NamespaceURI 具有值 http://www.w3.org/2000/xmlns/。


冒号为里面的关键字,
--------------------编程问答--------------------

XmlDocument doc = new XmlDocument();
 XmlElement root = doc.CreateElement("offers");
 doc.AppendChild(root);
 XmlAttribute xsi = doc.CreateAttribute("xmlns:xsi");
 xsi.Value = "http://www.w3.org/2001/XMLSchema-instance";
 XmlAttribute xsispace = doc.CreateAttribute("xsi:noNamespaceSchemaLocation","http://www.w3.org/2001/XMLSchema-instance");
 xsispace.Value = "feed.xsd";
 root.Attributes.Append(xsi);
 root.Attributes.Append(xsispace);

这样就OK了
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,