开发者

Get data from specific HTML table cells using Php

开发者 https://www.devze.com 2023-01-23 00:38 出处:网络
I need to get the data out of all of the table cells in the 4th row of the 4th table on an HTML page. After researching for a while, it seems that using DOMXPath is the best way to parse the HTML file

I need to get the data out of all of the table cells in the 4th row of the 4th table on an HTML page. After researching for a while, it seems that using DOMXPath is the best way to parse the HTML file. However, no IDs or classes are used anywhere in the file. W开发者_如何学JAVAhat would be the best way to get the data out of these cells?

Thanks in advance.


You can specify an index when fetching with XPath. In your case

/html/body/table[4]/tbody/tr[4]/td

Note that an XPath index is not zero-based, but one-based.


If you are familiar with jQuery syntax, have you looked into phpQuery?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号