Faton Ramadani
Faton Ramadani

Reputation: 65

Cheerio not finding table content

I need to parse an HTML containg a table.

<div>
<table id="tableID">
    <tr>
        <td class="tdClass">
            <span id="id1">Some data i need to access</span>
        </td>
        <td class="tdClass">
            <span id="id2">Some data i need to access</span>
        </td>
    </tr>
</table>
</div>

I'm using cheerio on a NW.js app. I can't figure out how to access the datas, I've tried with span's ids, but it doesn't work.

The div is contained in the body of the page.

var $ = cheerio.load(html)
alert($('#id1').html())

I'm getting null when I'm trying to alert the content of the span.

Upvotes: 0

Views: 422

Answers (1)

user3641340
user3641340

Reputation: 11

Try this:

$ = cheerio.load(html, {normalizeWhitespace: false, xmlMode: true});

Upvotes: 1

Related Questions