1

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!

v.g.
  • 1,076
  • 5
  • 19
  • 38

2 Answers2

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
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

Community
  • 1
  • 1
har07
  • 88,338
  • 12
  • 84
  • 137