【发布时间】:2020-08-30 09:41:45
【问题描述】:
我正在尝试从下面的 TR 代码中获取 2 个值
1) xyz.com 2) 这太好了,我会给 100 美元
以下是我尝试 Xpath/Parse 的 HTML 代码,但无法获得所需的结果。
<tr class="something-is-here">
<td>xyz.com</td>
<td class="text-right">
<span>this is great i will give 100 bucks
</span>
</td>
</tr>
尝试了以下方法,但似乎不起作用。
$html = new simple_html_dom();
$html->load($content);
foreach($html->find('tr') as $myLink) {
$href = $myLink->span;
if (!is_null($myLink)) {
foreach ($myLink as $element) {
$nodes = $element->childNodes;
foreach ($nodes as $node) {
echo $node->nodeValue. "\n";
}
}
}
非常感谢任何帮助。 谢谢。
【问题讨论】:
-
我没有看到足够的右花括号。您对代码无法正常工作的确切表达不能再模糊/无用了。我们希望查看您生成的错误(如果有)和不正确的输出,如果您(通过基本诊断)缩小了失败的行,请说明。