How to get full HTML and have HTML entities not escaped?
See original GitHub issueUsing HtmlParser
, I’m changing some nodes. E.g. I’m inserting something like —
and other entities.
When accessing the InnerHtml
property, the (e.g.) —
is returned as —
. This is wrong in my scenario.
In contrast, the TextContent
returns —
correctly but omits all contained HTML tags.
My question:
Is there a way to get the full content of the HtmlParser
without HTML entities being “destroyed”?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Getting inner html without escaping or decoding anything ...
For anyone asking this in 2021.. My solution was to take the text in place it in a different textarea using .innerHTML ,...
Read more >HTML Escape Characters: Complete List of HTML Entities
Number Symbol Entity Name Code Description
9 Tab &Tab 	 Tab
10 New Line &NewLine 
 New Line
32 Space     Space
Read more >htmlentities - Manual
When double_encode is turned off PHP will not encode existing html entities. The default is to convert everything. Return Values ¶. Returns the...
Read more >How to escape & unescape HTML characters in string ...
Escaping HTML characters in a string means replacing the: ... We can escape the HTML of the string using the replace method of...
Read more >HTML: No, you don't need to escape that - mina86.com
It would make sense to conclude that escaping is required if an ampersand is followed by one of those characters, which is probably...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks Uwe! I’m glad you found a workaround / solution for your problem. Always at your service!
Thanks for giving me some context. Yes, from the snippet it seems that this is indeed the problem. The
NodeValue
is quite a generic property, which maps to nothing except forCharacterData
nodes (e.g., comments or text nodes) and entities (which are not used in HTML as they are resolved directly; this is an historic type of node that is a left-over from XML). Hence you already set the literal text (same as settingTextContent
).Either you use the previously mentioned
HtmlEntityService
to do the conversion yourself, or you leave it up to a parser by parsing a fragment of the snippet you want to insert.