通过php脚本解析html表并将其打印在我们的页面上


parsing html table by php script and printing it on our page

我这里有一个表,其中包含一些数据,所以我想复制这些数据,并想通过php脚本将其打印在我的网页上,所以请有人帮助我,如果你不介意有人在这里为这个问题贡献合适的代码。

使用类似SimpleHTMLDom的DOM解析器。

include 'simple_html_dom.php';
$html = file_get_html('http://result.msrit.edu/getresult.php?myusn=1ms10cs410&B1=GET%20RESULT');
$elems = $html->find("/html/body/table/tbody/tr[1]/th[1]/div"); 
foreach($elems as $v) 
{
//do the parsing here 
}

阅读文档以了解可用的选项和示例。

希望这能有所帮助!

$dom = new DomDocument();
@$dom->loadHTML(file_get_contents ('http://result.msrit.edu/getresult.php?myusn=1ms10cs410&B1=GET%20RESULT'));
$table=$dom->getElementsByTagName('table');
echo $dom->saveHTML($table->item(0));