[英]Parse HTML string into DOM using JavaScript, but ignore broken tags
I have the following HTML string: 我有以下HTML字符串:
"<div> one is<than three </div>"
is there an elegant way to parse this string to HTML using JavaScript? 有没有一种优雅的方法可以使用JavaScript将字符串解析为HTML? Every solution tends to create
<than
tag. 每个解决方案都倾向于创建
<than
标签。 Can anyone advise me on this issue, or should I change the solution to avoid this? 谁能在这个问题上给我建议,还是应该更改解决方案以避免这种情况?
(Even StackOverflow has an issue if I put <than
as a plain text) (如果我将
<than
作为纯文本放置,即使StackOverflow也有问题)
As <
shouldn't be part of valid HTML document, you should consider using <
由于
<
不应成为有效HTML文档的一部分,因此您应考虑使用<
character. 字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.