Showing posts with label XDocument. Show all posts
Showing posts with label XDocument. Show all posts

Wednesday, July 2, 2014

How to load XML file located inside the folder of the application in window phone 8

Problem:

I have some onboard xml files which I needed to load into memory.  I was puzzling over how to load them into memory for use in my app.  I tried using XDocument library but I kept getting the error:
"Cannot find file '/XML Files/A.xml' in the application xap package.

XDocument doc = XDocument.Load( "XML Files/MyXmlFile.xml" );

This was not working.  I tried several variations but still was getting the error every time I ran to code.

Solution:
It turns out that my syntax was not the problem.  I needed to set the properties on the xml file correctly. 

1.) Build Action=Content
2.)Copy to output=Copy if newer (or Copy always).


Source:

http://stackoverflow.com/questions/4538874/how-to-load-xml-file-located-inside-the-folder-of-the-application-in-window-phon