lizandpedia
New Member
I'm attempting to open an XML file which is copied as content to the \[code\]IsolatedStorage\[/code\] when I compile my app and am having some issues with it; \[quote\] Data at the root level is invalid. Line 1, position 411.\[/quote\]I'm not entirely sure what this means and a trip to my local search engine only expanded my confusion, could anybody please tell me if I'm doing anything drastically wrong or if my data structure is bad please?Here's my function that loads the data from the file and parses it into variables:\[code\]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 = http://stackoverflow.com/questions/13808144/from query in document.Descendants("myData") select new DataHolder { CashData = http://stackoverflow.com/questions/13808144/(string)query.Element("CashData"), LandGoData = http://stackoverflow.com/questions/13808144/(string)query.Element("LandGoData"), FreeParkingData = http://stackoverflow.com/questions/13808144/(string)query.Element("FreeParkData"), CircuitData = http://stackoverflow.com/questions/13808144/(string)query.Element("FullCircuitData"), AuctionData = http://stackoverflow.com/questions/13808144/(string)query.Element("AuctionData") }; listBox.ItemsSource = data; StartCashRule.Text = (string)listBox.FindName("myData"); } } fileStream.Close(); } } }\[/code\]And here's my xml document:\[code\]<?xml version="1.0" encoding="utf-8" ?><RootPath> <CashData>Value1</CashData> <LandGoData>Value2</LandGoData> <FreeParkData>Value3</FreeParkData> <FullCircuitData>Value4</FullCircuitData> <AuctionData>Value5</AuctionData></RootPath>\[/code\]