在找到 TD 后选择同一 TR 中的 TD


select tds in same tr after of found td

我已经通读了文档并进行了搜索,但我仍然像开始时一样无知。

我正在尝试从此页面中选择特定元素。

我知道如何用id="Source"找到td,但我不知道如何在同一tr中选择后续td

请帮忙。

提前非常感谢!

您可以在没有 xpath 查询的情况下执行此操作:

$xmlErrors = libxml_use_internal_errors(true);
$dom = new DomDocument();
$dom->loadHtml($sourceHtml);
$tr = $dom->getElementById('Source')->parentNode;
foreach($tr->childNodes as $node)
  print $node->nodeValue;
libxml_clear_errors();
libxml_use_internal_errors($xmlErrors);