CsQuery
CsQuery copied to clipboard
Text() vs. InnerText vs. jQuery difference
I'm trying to get inner text of a node, however .InnerText property seems to misbehave:
> CQ.Create("<hai>foo & bar baz<br>qux</hai>").["hai"].[0].InnerText;;
"foo & bar bazqux"
Compare to jQuery:
> $("<hai>foo & bar baz<br>qux</hai>")[0].innerText
"foo & bar baz\nqux"
At the same time Text() seems to work closer to jQuery:
> CQ.Create("<hai>foo & bar baz<br>qux</hai>").["hai"].Text();;
"foo & bar bazqux"
Do you have a suggestion on how can I want to achieve behaviour similar to jQuery?
Write CsQuery.Config.OutputFormatter = OutputFormatters.HtmlEncodingNone; before any CQ use.
@alexander1986 thanks, that makes output of .InnerText similar to .Text(). Although I wish I could get the exact behavior of jQuery.