C# 生成xml属性
我必须创建一个xml文件,其中包含一个具有以下属性的元素:C# 生成xml属性,c#,xml,namespaces,xelement,xattribute,C#,Xml,Namespaces,Xelement,Xattribute,我必须创建一个xml文件,其中包含一个具有以下属性的元素: <element xsi:schemaLocation="http://test.xsd" xmlns="http://test2" xmlns:xsi=http://test3> 但唯一产生罚款的是(III): (一) 生成的结果如下所示: p1:schemaLocation="http://test.xsd" xmlns:p1="xsi" 和(II)未生成,因为该行未编译 知道
<element
xsi:schemaLocation="http://test.xsd"
xmlns="http://test2"
xmlns:xsi=http://test3>
但唯一产生罚款的是(III):
(一) 生成的结果如下所示:
p1:schemaLocation="http://test.xsd" xmlns:p1="xsi"
和(II)未生成,因为该行未编译
知道如何生成这些属性吗
谢谢,,
L
编辑-也可以在此处找到它:
xmlns:xsi=http://test3
p1:schemaLocation="http://test.xsd" xmlns:p1="xsi"
const string ns = "http://test2";
const string si = "http://test3";
const string schema_location = "http://test.xsd";
XNamespace xns = ns;
XNamespace sinsp = si;
XElement xe = new XElement(xns + "element",
new XAttribute(XNamespace.Xmlns + "xsi", si),
new XAttribute(sinsp+ "schemaLocation", schema_location),
new XElement(xns + "sometag", "somecontent")
);
return xe;