如果我調試我的 Android 應用程序,如果我從 XmlDocument 中的字符串加載 xml,它總是會崩潰。加載到字符串中工作正常。錯誤:System.IO.DirectoryNotFoundException: Could not find a part of the path "/<?xml version="1.0" encoding="UTF-8"?><note> <to>edit</to></note>".我的代碼:private void Xmlload() { using (StreamReader streamReader = new StreamReader(Assets.Open("note.xml"))) { xmlString = streamReader.ReadToEnd(); } textView1.Text = xmlString; Xml(); } private void Xml() { XmlDocument doc = new XmlDocument(); doc.Load(xmlString); }謝謝你的幫助
1 回答

茅侃侃
TA貢獻1842條經驗 獲得超21個贊
該Load方法從路徑加載 XML。您想使用LoadXml,它加載一個包含 XML 的字符串
XmlDocument.Load(string path);
XmlDocument.LoadXml(string xml);
- 1 回答
- 0 關注
- 118 瀏覽
添加回答
舉報
0/150
提交
取消