Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Agility Pack Parsing With Upper & Lower Case Tags?

I am using the HTML Agility Pack to great effect, and am really impressed with it - However, I am selecting content like so

doc.DocumentNode.SelectSingleNode("//body").InnerHtml

How to I deal with the following situation, with different documents?

<body>
<Body>
<BODY>

Will my code above only get the lower case versions?

like image 381
YodasMyDad Avatar asked Apr 25 '11 07:04

YodasMyDad


Video Answer


1 Answers

The Html Agility Pack handles HTML in a case insensitive way. It means it will parse BODY, Body and body the same way. It's by design since HTML is not case sensitive (XHTML is).

That said, when you use its XPATH feature, you must use tags written in lower case. It means the "//body" expression will match BODY, Body and body, and "//BODY" will match nothing.

like image 85
Simon Mourier Avatar answered Nov 01 '22 11:11

Simon Mourier