PHP Simple HTML DOM - Get text inside <td> tag

PHP Simple HTML DOM - Get text inside <td> tag,php,simple-html-dom,Php,Simple Html Dom,So I have this .html file that I have to analyze. In that file I have lines like this one: <tr> <td colspan=1 rowspan=1 bgcolor=#ffffff align=left valign=top> <font size=1 face="Tahoma" color=#000000> <nobr> 240,0000 </nobr> </font> </td> <td colspan=1 rowspan=1 bgcolor=#ffffff align=left valign=top> <font size=1 face="Tahoma" color=#000000> <nobr&g

So I have this .html file that I have to analyze. In that file I have lines like this one:

<tr>
    <td colspan=1 rowspan=1 bgcolor=#ffffff align=left valign=top>
        <font size=1 face="Tahoma" color=#000000>
            <nobr>
                 240,0000
            </nobr>
        </font>
    </td>

     <td colspan=1 rowspan=1 bgcolor=#ffffff align=left valign=top>
        <font size=1 face="Tahoma" color=#000000>
            <nobr>
                 340,0000
            </nobr>
        </font>
    </td>
</tr>

What I need to get is 240,0000 , 340,0000 and so on. I have tried something like this:

// Create DOM from URL or file
$html = file_get_html('File.html');

foreach($html->find('td') as $element) 
   echo $element->text. '<br>';

Doing it this way I don't get the text I want to get.

How can I make reference to the text inside tag? So I can get the values.


#1

Nothing like $element->text Use $element->plaintext

foreach ( $html->find('td nobr') as $element ) {
    echo $element->plaintext . '<br>';
}

#2

does $html->find('nobr') not work for you? Or is it not always formatted the same?

#3

what do I echo after that to get the text?

#4

$element->paintext ^^

#5

Got it, but you're missing a letter: $element->plaintext I guess it was a typo :)

#6

hahaha, yeah, twas a typo. =]