我想提取<P>
標籤下的前兩個句子。如何從xml字符串中提取特定值?
例如(輸入字符串):
<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' is an unexpected token. The expected token is '"' or ''
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加載。 – wonderbell