私はVS2010を使用しており、HTMLAGilityPack1.4.6(Net40フォルダーから)を使用しています。以下は私のHTMLです
<html>
<body>
<div id="header">
<h2 id="hd1">
Patient Name
</h2>
</div>
</body>
</html>
「hd1」にアクセスするために、C# で次のコードを使用しています。正しいやり方を教えてください。
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
try
{
string filePath = "E:\\file1.htm";
htmlDoc.LoadHtml(filePath);
if (htmlDoc.DocumentNode != null)
{
HtmlNodeCollection _hdPatient = htmlDoc.DocumentNode.SelectNodes("//h2[@id=hd1]");
// htmlDoc.DocumentNode.SelectNodes("//h2[@id='hd1']");
//_hdPatient.InnerHtml = "Patient SurName";
}
}
catch (Exception ex)
{
throw ex;
}
多くの順列と組み合わせを試しました...私はnullになります。
助けてください。