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");
xsispace.Value = "feed.xsd";
root.Attributes.Append(xsi);
root.Attributes.Append(xsispace);
我这样写,生成出来的是这样的
<offers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" noNamespaceSchemaLocation="feed.xsd">但要求是这样的
<offers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="feed.xsd">
后面的那个xsi:不知道咋弄不出来
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");
xsispace.Value = "feed.xsd";
root.Attributes.Append(xsi);
root.Attributes.Append(xsispace);
我这样写,生成出来的是这样的
<offers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" noNamespaceSchemaLocation="feed.xsd">但要求是这样的
<offers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="feed.xsd">
后面的那个xsi:不知道咋弄不出来
解决方案 »
- 点击datagrid中的按钮 在事件中怎么取到当前所点击行数据的id
- oledbdataadapter的update方法可以这样用吗?
- Dictionary<int, string>怎么获取它的值的集合?急!急!急!
- 打开新窗体时候,暂停原窗体,直到新窗体关闭
- C# 中的四舍五入函数及 Math.Round 勘误
- 大批量数据上传
- 简单的关于反射的一个问题.
- 如何将第二个窗体依靠在第一个窗体的panel控件上.即在第一个窗体的panel控件上显示.(c#)
- 关于C#中继承的问题
- C#获取webBrowser内容获取不到
- 请问一个正则表达式的问题
- 报错:ROLLBACK TRANSACTION 请求没有对应 BEGIN TRANSACTION
把这句话改成这个
XmlAttribute xsispace = doc.CreateAttribute("noNamespaceSchemaLocation");
不行吗。
不行用记事本的形式,用StreamWriter往XML文件里写吧
看下这个里面的方法
XDocument Orders = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), new XElement("Orders", new XAttribute(XNamespace.Xmlns + "xsi", xsi), new XAttribute(xsi + "noNamespaceSchemaLocation", "feed.xsd")));
Orders.Save("E:\\1.xml");
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);