Welcome to EMC Consulting Blogs Sign in | Join | Help

Julian R Harris, Social Computing Guy

My work blog. Social Computing with Agile Software Delivery. See also my personal blog.

How to access InnerHtml and InnerText properties of an html <select><option> tag when using the HtmlAgilityKit

(I'm in geek mode at the moment because I've been setting up an automated test framework for the project I'm managing, which has seen me learn C#, which is fun. So I guess I'm not a typical PM. But I digress...) 

Context: you want to parse some HTML using XPATH in C#. All roads appear to point to HtmlAgilityKit. I specifically was trying to do is make it really easy for testers to check the contents of dropdown lists so I write a Custom ValidationRule for Microsoft WebTest called 'ValidateDropdown' which could also easily be called 'ValidateSelect' but Select is such a uselessly generic term.

Problem: HTML defines select option like this:

<select ... ><option value="[value]">[InnerHtml]

This means the 'InnerHtml' is not associated with the option tag.

XHTML however defines it like this:

<select ... ><option value="[value]">[InnerHtml]</option>

HtmlAgilityToolkit was driving me nuts because it was actually doing strictly the right thing -- ignoring the InnerHTML. The fix is easy -- see link to forum

 Enjoy!

 

 

Published 11 September 2007 13:28 by Julian.RHarris

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit

About Julian.RHarris

Passionate technologist and toolbuilder. Music composer and photographer. Deep fascination and participation in the conversation of how technology can aid people become more empowered.
Powered by Community Server (Personal Edition), by Telligent Systems