html-react-parser icon indicating copy to clipboard operation
html-react-parser copied to clipboard

unable to rightly parse html when it contain some html tags with no ends.

Open AlenToma opened this issue 4 years ago • 2 comments

I am unable to parse the current html from some reason

<div>
<div id="chr-content">
<span>
  lkjasdkjasdkljakldj
</div>
</div>
`

My current Code is

  const validate =()=> {
       var h = html.replace(/<!DOCTYPE html>/g, "").
          replace(/[[class]]/g, "").
          replace(/[[id]]/g, "")
    var container = parse("<div>" + h + "</div>");
       var content = container.querySelector("#chr-content");
        setFound(content != null ? "found" : "not found")
  }

This is on Node.js with the latest version 4.1.4

Here is snack example if you would like to test

snack

AlenToma avatar Sep 12 '21 23:09 AlenToma

Apologies for the late response @AlenToma but are you still unable to parse the HTML?

remarkablemark avatar Dec 10 '21 05:12 remarkablemark

I am using it together with react-native-html-parser

react-native-html-parser will enclose all open html tags and then I parse the html again.

AlenToma avatar Dec 10 '21 08:12 AlenToma