HtmlAgilityPack immediately closes the form tag.

.net html html-agility-pack

Question

I'm trying to use the following code to parse an HTML file:

<div><form>...</div>...</form>

The issue is that the HTML Agility Pack closes the form element before the div ending tag automatically:<div><form>...</form></div>...</form> As a result, several form components are missing when I parse the form. (I only get the components before the tag that was applied automatically.)

I have previously tried

htmlDoc.OptionFixNestedTags = false;
htmlDoc.OptionAutoCloseOnEnd = false;
htmlDoc.OptionCheckSyntax = false;
HtmlNode.ElementsFlags.Remove("form");
HtmlNode.ElementsFlags.Add("form", HtmlElementFlag.CanOverlap);
HtmlNode.ElementsFlags.Add("div", HtmlElementFlag.CanOverlap);

But it's useless!

I appreciate your support.

1
2
8/18/2011 4:28:23 PM

Popular Answer

I've found the following to be effective:

HtmlAgilityPack.HtmlNode.ElementsFlags.Remove("form");

_document = new HtmlDocument();
_document.OptionAutoCloseOnEnd = true;
_document.LoadHtml(content);
1
4/12/2012 7:40:39 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow