.NET XMLDoccument handling in C#

Given the below C# code using VS2005:
       XmlDocument xn = new XmlDocument();

Please advise the remaini ng code to accomplish the following:
1) Fill xn with an XML file and make it a useable XML document ready to be sent to a WS
2) Do the same as (1) with a string storing the same XML data.

Who is Participating?
JimBrandleyConnect With a Mentor Commented:
If this is a web app,

string path = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath + "\\app_data\\MyFile.xml");

If it's a windows app, you can just use the complete path to that directory, or if it's under the directory where your application resides, just:

string path = "app_data\\MyFile.xml";

To load from a file:

To load from a string containg XML:
xn.LoadXml( myXMLstring );

ksfokAuthor Commented:
How would I handle "xn.Load(myFilePath);" if an XML file is placed under app_data folder?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.