How do I parse an HTML file in React Native?

Just download HTML with fetch(), parse it using fast-html-parser, write result to state and render that state with WebView


Get html with fetch() and parse with react-native-html-parser, process and display with WebView.

import DOMParser from 'react-native-html-parser';

fetch('http://www.google.com').then((response) => {
   const html = response.text();    
   const parser = new DOMParser.DOMParser();
   const parsed = parser.parseFromString(html, 'text/html');
   parsed.getElementsByAttribute('class', 'b');
});

P.S. fast-html-parser from other answers didn't work for me. I got multiple errors while installing it with react-native 0.54.