Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 476 Bytes

parse-html.md

File metadata and controls

24 lines (17 loc) · 476 Bytes

How to parse an HTML page with React

You can use the node-html-parser npm package:

import { parse } from 'node-html-parser';

function App() { 
  const root = parse('<ul id="list"><li>Hello World</li></ul>');

  const text = root.querySelector('#list li').innerText;
  
  return (
    <div>
      {text}
    </div>
  );
}

export default App;

References: