I'm trying to extract text from html using the innerText attribute like such: console.log(document.getElementById('row').innerText)
However, the output is not in the same fashion as I see it on the browser.
The reason for the difference is that the table element in the first situation contains style of inline-block (see below).
How can I solve it so I get the text in the same format as it appears in browser?
Situation # 1: Input:
<html>
<body id='test'>
<table style="display: inline-block">
<tr>
<td>1</td>
</tr>
<tr>
<td>2</td>
</tr>
</table>
<table style="display: inline-block">
<tr>
<td>3</td>
</tr>
<tr>
<td>4</td>
</tr>
</table>
</body>
</html>
Expected Output:
1 3
2 4
Actual Output
1
2
3
4
Situation # 2: Input:
<html>
<body id='test'>
<table>
<tr>
<td>1</td>
</tr>
<tr>
<td>2</td>
</tr>
</table>
<table>
<tr>
<td>3</td>
</tr>
<tr>
<td>4</td>
</tr>
</table>
</body>
</html>
Expected Output:
1
2
3
4
Actual Output
1
2
3
4