I doesn't read the XML file, it show the error like this LoadXml(responseString)
"The name 'LoadXml' does not exist in the current context".I used two way to read the XML .is there an other way to read XML
我没有读取XML文件,它显示错误,如此LoadXml(responseString)“当前上下文中不存在名称'LoadXml'。”我使用两种方式来读取XML。还有另一种方法可以读取XML
Stream str = null;
StreamReader responseReader = new StreamReader(str);
//StreamReader sr=new StreamReader(str);
string responseString = responseReader.ReadToEnd();
//xmlDoc.LoadXml(sr.ReadToEnd());
xmlDoc.LoadXml(responseString);
responseReader.Close();
//sr.Close();
str.Close();
can any one help me to get rid out of this
任何人都可以帮我摆脱这个
1 个解决方案
#1
0
XmlDocument.LoadXml loads a XML string directly.
XmlDocument.LoadXml直接加载XML字符串。
xmlDoc.Load("<hello></hello>");
What you need is XmlDocument.Load(TextReader). Note that StreamReader extends TextReader.
你需要的是XmlDocument.Load(TextReader)。请注意,StreamReader扩展了TextReader。
using (StreamReader responseReader = new StreamReader(str)) {
xmlDoc.LoadXml(reasponseReader);
}
#1
0
XmlDocument.LoadXml loads a XML string directly.
XmlDocument.LoadXml直接加载XML字符串。
xmlDoc.Load("<hello></hello>");
What you need is XmlDocument.Load(TextReader). Note that StreamReader extends TextReader.
你需要的是XmlDocument.Load(TextReader)。请注意,StreamReader扩展了TextReader。
using (StreamReader responseReader = new StreamReader(str)) {
xmlDoc.LoadXml(reasponseReader);
}