【发布时间】:2015-04-16 09:17:37
【问题描述】:
我想提取<P> 标签下的第一个两个句子。
例如(输入字符串):
<P align=justify><STRONG>Pricings<BR></STRONG>It was another active week for names leaving the database. The week's prints consisted of two ILS, and sever ITS.</P>
需要的输出字符串:
It was another active week for names leaving the database. The week's prints consisted of two ILS, and sever ITS.
目前,我下面的函数抛出以下错误:
System.Xml.XmlException: 'justify' 是一个意外的标记。预期的标记是 '"' 或 ''
price = bottom.Substring(bottom.IndexOf("Pricings"), 8);
XmlDocument doc = new XmlDocument();
doc.LoadXml(bottom);
XmlNodeList pList = doc.SelectNodes("/P[@align='justify']/strong");
foreach (XmlNode pValue in pList)
{
string innerText = pValue.ChildNodes[0].InnerText;
innerText = result;
}
我不太清楚,如何解决这个问题。感谢您提供任何进一步的帮助。
【问题讨论】:
-
您的 HTML 不是有效的 XML 字符串。无法使用 XmlDocument 加载。
标签: c# xml xmldocument