Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text() vs. InnerText vs. jQuery difference #193

Open
keleshev opened this issue Jul 2, 2015 · 2 comments
Open

Text() vs. InnerText vs. jQuery difference #193

keleshev opened this issue Jul 2, 2015 · 2 comments

Comments

@keleshev
Copy link

keleshev commented Jul 2, 2015

I'm trying to get inner text of a node, however .InnerText property seems to misbehave:

> CQ.Create("<hai>foo &amp; bar &nbsp; baz<br>qux</hai>").["hai"].[0].InnerText;;
"foo &amp; bar &nbsp; bazqux"

Compare to jQuery:

> $("<hai>foo &amp; bar &nbsp; 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 &amp; bar &nbsp; 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?

@keleshev keleshev changed the title Text() vs. InnerText differenct Text() vs. InnerText vs. jQuery difference Jul 2, 2015
@asv7c2
Copy link

asv7c2 commented Jul 5, 2015

Write
CsQuery.Config.OutputFormatter = OutputFormatters.HtmlEncodingNone;
before any CQ use.

@keleshev
Copy link
Author

keleshev commented Jul 7, 2015

@alexander1986 thanks, that makes output of .InnerText similar to .Text(). Although I wish I could get the exact behavior of jQuery.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants