XmlDocument - loading from a string?

protected void Page_Load(object sender, EventArgs e) { XmlDocument doc = new XmlDocument(); try { string path = Server.MapPath("."); doc.Load(path+"whatever.xml"); } catch (Exception ex) { lblError.Text = ex.ToString(); return; } // Convert XML to a JSON string string JSON = XmlToJSON(doc); // Replace \ with \\ because string is being decoded twice JSON = JSON.Replace(@"\", @"\\"); // Insert code to process JSON at end of page ClientScriptManager cs = Page.ClientScript; cs.RegisterStartupScript(GetType(), "SpaceJSON", "space_processJSON('" + JSON + "');", true); } 

Instead of loading xml from a file, how to load it from a string?

+73
json c # xml
Feb 08 2018-11-11T00:
source share
1 answer
 XmlDocument doc = new XmlDocument(); doc.LoadXml(str); 

Where str is your XML string. See the MSDN article for more information.

+174
Feb 08 2018-11-11T00:
source share
— -



All Articles