IsolatedStorage
アプリをコンパイルするときにコンテンツとしてコピーされる XML ファイルを開こうとしていますが、問題が発生しています。
ルート レベルのデータは無効です。行 1、位置 411。
これが何を意味するのか完全にはわかりませんし、私のローカル検索エンジンへの旅行は私の混乱を拡大するだけでした.私が何か根本的に間違ったことをしているのか、それとも私のデータ構造が悪いのか誰か教えてください.
ファイルからデータをロードし、変数に解析する関数は次のとおりです。
private void ReadData()
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
if (store.FileExists("appdata.xml"))
{
IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream("appdata.xml", FileMode.Open, store);
XDocument document;
using (XmlReader reader = XmlReader.Create(fileStream))
{
if (reader != null)
{
document = XDocument.Load(reader); // <-- Error occurs here
ListBox listBox = new ListBox();
var data = from query in document.Descendants("myData")
select new DataHolder
{
CashData = (string)query.Element("CashData"),
LandGoData = (string)query.Element("LandGoData"),
FreeParkingData = (string)query.Element("FreeParkData"),
CircuitData = (string)query.Element("FullCircuitData"),
AuctionData = (string)query.Element("AuctionData")
};
listBox.ItemsSource = data;
StartCashRule.Text = (string)listBox.FindName("myData");
}
}
fileStream.Close();
}
}
}
そして、ここに私のxmlドキュメントがあります:
<?xml version="1.0" encoding="utf-8" ?>
<RootPath>
<CashData>Value1</CashData>
<LandGoData>Value2</LandGoData>
<FreeParkData>Value3</FreeParkData>
<FullCircuitData>Value4</FullCircuitData>
<AuctionData>Value5</AuctionData>
</RootPath>