HtmlAgilityPack immediately closes the form tag.

.net html html-agility-pack

Question

I am tring to parse an html file with this code:

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

the problem is that the HtmlAgilityPack automatically close the form tag before the div ending tag: <div><form>...</form></div>...</form> so when I parse the form some of the form elements are missing. (I get only the elements befor the automatically added tag)

I already 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 nothing helps!

thanks for you help!

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

Popular Answer

The following seems to work for me:

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