[ create a new paste ] login | about

Link: http://codepad.org/s3r6mggB    [ raw code | output | fork ]

PHP, pasted on Mar 8:
<?php

$html = <<< HTML
<table id=myid>
<tr>
<td>value1</td>
<td>value2</td>
</tr>
<tr>
<td>value1</td>
<td>value2</td>
</tr>
</table>
HTML;

echo LIBXML_VERSION;

$dom = new DOMDocument();
$dom->validateOnParse = true;
$dom->loadHTML($html);
$table = $dom->getElementById('myid');
$table=$dom->getElementById('myid');
foreach($table->getElementsByTagName('tr') as  $key =>$tr){
    echo $tr->getElementsByTagName('td')->item(0)->nodeValue;
}


Output:
1
2
20628
Fatal error: Call to a member function getElementsByTagName() on a non-object on line 23


Create a new paste based on this one


Comments: