【发布时间】:2016-04-28 14:50:27
【问题描述】:
所以我试图从/in .xml 文件中读取和写入,我得到了这个错误:
'System.Xml.Linq.XDocument' does not contain a definition for 'load' and no extension method 'load' accepting a first argument of type 'System.Xml.Linq.XDocument' could be found (are you missing a using directive or an assembly reference?)
换行:
document.load("MyXmlFile.xml");
代码示例:
using System.Xml.Linq; // I included this for XDocument
using System.Xml.XPath; // I included this because I thought it will fix a problem
public partial class MainWindow : Window
{
public MainWindow() => InitializeComponent();
public void LoadXML()
{
var document = new XDocument();
if (!File.Exists("MyXmlFile.xml"))
document.Save("MyXmlFile.xml");
else document.load("MyXmlFile.xml");
}
}
【问题讨论】:
标签: c# xml wpf visual-studio-2010