这是我将数据添加到 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。