このテキストからList()を取得するにはどうすればよいですか?
For the iPhone do the following:<ul><li>Go to AppStore</li><li>Search by him</li><li>Download</li></ul>
構成する必要があります:AppStoreに移動し、彼で検索し、ダウンロードします
このテキストからList()を取得するにはどうすればよいですか?
For the iPhone do the following:<ul><li>Go to AppStore</li><li>Search by him</li><li>Download</li></ul>
構成する必要があります:AppStoreに移動し、彼で検索し、ダウンロードします
文字列をHTMLAgilityPackにロードしてから、すべてのli
要素の内部テキストを選択します。
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml("following:<ul><li>Go to AppStore</li><li>Search by him</li><li>Download</li></ul>");
var uls = doc.DocumentNode.Descendants("li").Select(d => d.InnerText);
foreach (var ul in uls)
{
Console.WriteLine(ul);
}
XMLルート要素でラップし、LINQtoXMLを使用します。
var xml = "For the iPhone do the following:<ul><li>Go to AppStore</li><li>Search by him</li><li>Download</li></ul>";
xml = "<r>"+xml+"</r>";
var ele = XElement.Parse(xml);
var lists = ele.Descendants("li").Select(e => e.Value).ToList();
で戻りますlists
:
Go to AppStore
Search by him
Download