In the root of my solution I have a XML file, which content I want to write to a string, because later I parse this string. What is the easiest way in WP8. I dont want to parse anything, just my string to have the content of the xml file, then I use this string the way I do now. Or the file needs to be txt with xml inside, I dont care. Thanks!
Asked
Active
Viewed 5,218 times
2 Answers
3
how about
using System.Xml.Linq;
// load the file using;
var xDocument = XDocument.Load(@"C:\MyFile.xml");
// convert the xml into string
string xml = xDocument.ToString();

Matthew Flynn
- 3,661
- 7
- 40
- 98
-
-
3c:\ is an example path.... you could try changing this when you copy / paste it over?? – Alex Oct 06 '14 at 11:59
1
You may want to try this :
StreamResourceInfo strm = Application.GetResourceStream(new Uri("/myProject;component/States.xml",UriKind.Relative));
StreamReader reader = new StreamReader(strm.Stream);
string xmlData = reader.ReadToEnd();
[Nokia developer community wiki: Parse Local XML file in Windows Phone]
or another possible way as shown in this other SO question : Windows Phone 8 - reading and writing in an existing txt file in the project