PHP Simple HTML DOM - Get text inside the <td> tag
So, I have this .html file that I have to parse. In this file, I have lines like this:
<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> I need to get 240,0000, 340,0000 and so on. I 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>'; By doing this, I do not get the text I want to receive.
How can I link to text inside a tag? Therefore, I can get the values.
+7
Francisco ochoa
source share1 answer
Nothing like $element->text Use $element->plaintext
foreach ( $html->find('td nobr') as $element ) { echo $element->plaintext . '<br>'; } +12
Baba
source share