Dmitry Petukhov Dmitry Petukhov -4 years ago 314
HTML Question

How do I parse an HTML file in React Native?

How can I get an HTML file from file system and parse specific elements from it.

For example, given the html snippet below, how can I extract the table content and render it?



<html>
<div>
<h1>header</h1>
<table id="a" border="1">
<th>Number</th>
<th>content A</th>
<th>contetn A</th>
<th>content A</th>
<tr>
<td>1</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<th>Number</th>
<th>content B</th>
<th>content B</th>
<th>content B</th>

<tr>
<td>1</td>
<td>b</td>
<td>b</td>
<td>b</td>
</tr>
</table>
</div>
<br>
<footer>footer</footer>

</html>




Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download