这是我的添加数据到XML的代码:
这是 People.xml:
当我点击按钮时出现以下错误:
IsolatedStorageFile isstore = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream bookfile = new IsolatedStorageFileStream("People.xml", System.IO.FileMode.Open, isstore);
XDocument xmldetails = XDocument.Load(bookfile);
XElement books =
new XElement("person",
new XAttribute("id", "5"),
new XAttribute("name", "Book Title"),
new XAttribute("beneficiary", "Book Author"),
new XAttribute("description", "Book Author"),
new XAttribute("deadline", "Book Author"),
new XAttribute("price", "Fiction"));
xmldetails.Root.Add(books);
xmldetails.Save(bookfile);
bookfile.Close();
这是 People.xml:
<?xml version="1.0" encoding="utf-8" ?>
<people>
<person index="1" name="Zlecenie numer jeden" beneficiary="Kowalski" description="Proste zlecenie jakiejs strony czy cos" price="800" deadline="27.12.2013" />
</people>
当我点击按钮时出现以下错误:
根级别的数据无效。第 1 行,第 1 个位置。