Eri*_*Cal 1 c# xml linq linq-to-xml
我正在构建一个xml文件.该文件的一部分是静态的.一些文件是动态的.我的代码有一个"空对象引用"错误.
任何提示都会很棒.
private XElement BuildDataElement()
{
// this is going to be more complicated
return new XElement("data");
}
public void TestXML(string fname)
{
// build the data element
XElement allData = BuildDataElement();
// Build the header
XDocument doc = new XDocument(
new XElement("map",
new XAttribute("showLabels", "1"),
new XAttribute("includeNameInLabels", "1"),
new XElement("colorRange",
new XElement("color",
new XAttribute("minValue", "1")
)
),
allData,
new XElement("application",
new XElement("apply",
new XAttribute("toObject", "TOOLTIP"),
new XAttribute("styles", "TTipFont,MyDataPlotStyle")
)
)
)
);
if (File.Exists(fname))
File.Delete(fname);
doc.Save(fname);
}
Run Code Online (Sandbox Code Playgroud)
任何提示都会很棒.
你说对了.这是我的提示:
| 归档时间: |
|
| 查看次数: |
657 次 |
| 最近记录: |