Programing

XmlDocument-문자열에서로드 하시겠습니까?

lottogame 2020. 9. 20. 10:28
반응형

XmlDocument-문자열에서로드 하시겠습니까?


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);
}

파일에서 xml을로드하는 대신 문자열에서 어떻게로드합니까?


XmlDocument doc = new XmlDocument();
doc.LoadXml(str);

strXML 문자열은 어디에 있습니까 ? 자세한 내용은 MSDN 문서 를 참조하십시오.

참고 URL : https://stackoverflow.com/questions/4929653/xmldocument-load-from-string

반응형