Я хотел бы извлечь 1-е два предложения под тегом <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