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

HtmlNode.InnerText Not working properly #427

Open
ghost opened this issue Mar 2, 2021 · 2 comments
Open

HtmlNode.InnerText Not working properly #427

ghost opened this issue Mar 2, 2021 · 2 comments
Assignees

Comments

@ghost
Copy link

ghost commented Mar 2, 2021

InnerText returns " "

1. Description

<p id="demo">hello &nbsp; </p>

var text =htmlNode.InnerText;

//Get:  

"hello &nbsp; "

//Expected:
"hello   "

4. Any further technical details

Add any relevant detail can help us, such as:

  • HAP version: 1.8.1
  • NET version: .NET 4.0
@JonathanMagnan JonathanMagnan self-assigned this Mar 2, 2021
@JonathanMagnan
Copy link
Member

Hello @MartinHenkeQP ,

Due to some backward compatibility, we choose to let this work like this. Many people use the library to parse text and would have expected to get the &nbsp; and not a space (even if space is really what should have been expected).

From the past experience, we learned that this small kind of fix generally causes a lot of issues for people using our library in their production environment, so we try as much as possible to don't touch it.

You can on your side fix it by simply decoding the HTML:

HtmlDocument htmlDocument = new HtmlDocument(); 
htmlDocument.LoadHtml(@"<p id=""demo""> hello &nbsp; </p>"); 

var text = HttpUtility.HtmlDecode( htmlDocument.DocumentNode.InnerText);

Best Regards,

Jon


Performance Libraries
context.BulkInsert(list, options => options.BatchSize = 1000);
Entity Framework ExtensionsEntity Framework ClassicBulk OperationsDapper Plus

Runtime Evaluation
Eval.Execute("x + y", new {x = 1, y = 2}); // return 3
C# Eval FunctionSQL Eval Function

@ghost
Copy link
Author

ghost commented Mar 9, 2021 via email

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

No branches or pull requests

1 participant