HTML 민첩성 팩을 사용하여 특정 ID와 그 하위가있는 div를 제거하는 데 문제가 있습니다. 나는 단지 설정 옵션이 빠졌을 것이라고 확신하지만, 금요일과 나는 고군분투하고있다.html 민첩성 팩 어린이 제거
단순화 된 HTML 실행 : 이것은 지금까지 내가 가지고 같다
<html><head></head><body><div id='wrapper'><div id='functionBar'><div id='search'></div></div></div></body></html>
. 민첩성 팩에 의해 발생 된 오류는이 사업부 구조를 찾을 수 없습니다 보여줍니다 (.... 유래에서 촬영) 여기
<div id='functionBar'></div>
지금까지 코드의를
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
// There are various options, set as needed
//htmlDoc.OptionFixNestedTags = true;
// filePath is a path to a file containing the html
htmlDoc.LoadHtml(Html);
string output = string.Empty;
// ParseErrors is an ArrayList containing any errors from the Load statement
if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count > 0)
{
// Handle any parse errors as required
}
else
{
if (htmlDoc.DocumentNode != null)
{
HtmlAgilityPack.HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//body");
if (bodyNode != null)
{
HtmlAgilityPack.HtmlNode functionBarNode = bodyNode.SelectSingleNode ("//div[@id='functionBar']");
bodyNode.RemoveChild(functionBarNode,false);
output = bodyNode.InnerHtml;
}
}
}
천재 - 감사합니다! –