本文介绍了解析实体名时发生错误。第1行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello All,
我在解析XML字符串时遇到异常。
这是异常 解析entityname;时发生的错误。第1行 和我使用的XML如下;
Hello All,
I have got an exception while parsing an XML string.
Here is the exception an error occurred while parsing entityname;. line 1 and the XML I have used is as follows ;
<Details CompanyName="Outlook & Outlook Express" ></Details>
代码如下:
StringReader strRdr = new StringReader(textBox1.Text);
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(strRdr);
XmlNode node = xmlDoc.DocumentElement.SelectSingleNode(@"/Details");
}
catch (Exception Ex)
{
System.Windows.Forms.MessageBox.Show(Ex.Message.ToString(), "XML Parsing");
}
如果有人可以帮我解决这个问题,那就太棒了。
问候
Sebastian
If someone can help me to solve this issue, that would be great.
Regards
Sebastian
推荐答案
StringReader strRdr = new StringReader("<Details CompanyName=\"Outlook & Outlook Express\" ></Details>");
如果需要,可在需要时将其解码。
If needed, decode it back when needed.
这篇关于解析实体名时发生错误。第1行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!