CHM を機能させるには、おそらく Windows エクスプローラーでプロパティを表示し、[コンテンツのブロックを解除する] チェックボックスをオフにする必要があります。
HTML Agility Pack は、Linq-to-XML または XPath の使い方を知っていれば非常に簡単です。
知っておくべき基本事項:
//import the HtmlAgilityPack
using HtmlAgilityPack;
HtmlDocument doc = new HtmlDocument();
// Load your data
// -----------------------------
// Load doc from file:
doc.Load(pathToFile);
// OR
// Load doc from string:
doc.LoadHtml(contentsOfFile);
// -----------------------------
// Find what you're after
// -----------------------------
// Finding things using Linq
var nodes = doc.DocumentNode.DescendantsAndSelf("input")
.Where(node => !string.IsNullOrWhitespace(node.Id)
&& node.Attributes["value"] != null
&& !string.IsNullOrWhitespace(node.Attributes["value"].Value));
// OR
// Finding things using XPath
var nodes = doc.DocumentNode
.SelectNodes("//input[not(@id='') and not(@value='')]");
// -----------------------------
// looping through the nodes:
// the XPath interfaces can return null when no nodes are found
if (nodes != null)
{
foreach (var node in nodes)
{
var id = node.Id;
var value = node.Attributes["value"].Value;
}
}
HtmlAgility Packを追加する最も簡単な方法は、NuGet を使用することです。
PM> インストール パッケージ HtmlAgilityPack