I am trying to parse a HTML table in a page.
However, it is not the only TABLE in the page, and I am only interested in parsing the 2nd <table>
instnace in the HTML page.
How do I specify to parse only the 2nd TABLE instance in the HTML page?
//the table by its tag name
$tables = $dom->getElementsByTagName('table');
使用DOMNodelist-> item()(item()期望索引作为参数,它是从零开始的,所以1将返回第二个表)
$table = $dom->getElementsByTagName('table')->item(1);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.