HtmlNode.InnerText Broken?

Topics: Developer Forum, User Forum
Dec 19, 2009 at 8:22 PM

Hey, I think I found a bug with whatever populates the InnerText value.

In my application, I select this node:

<option value="AE">
Aerospace Engineering
  </option>

And the InnerText (or InnerHtml) property on the node is string.Empty.  I suspect that because the inner text doesn't start until a new line, it doesn't catch it.  Can anyone confirm this? or even better tell me what I should do to fix this?

Dec 19, 2009 at 8:34 PM

I grabbed the source code and took a peek inside.  It seems Html Agility is classifying that node as an "element" with no child nodes.  Thus returns string.Empty (HtmlNode.cs line 396).

Anyone know why this is labeled as an element?

Coordinator
Dec 23, 2009 at 4:49 PM

Because of ... history!

Back then 10 years ago, HTML 3.2 allowed opening tags (such as <OPTION>) without a matching closing tag. Just change the Elements flags if you feel you don't want this "legacy" behavior :)