0
这里是我的代码:PHP - DOMXpath - 获取价值
$doc = new DOMDocument;
$doc->loadHTML($source);
$xpath = new DOMXPath($doc);
$result = $xpath->evaluate($xpath);
foreach($result as $node) {
echo $node->nodeValue;
}
//I'm trying to get the href attribute in: <a href="http://example.com/login">Log In</a>
当我评价它,我只得到登录。
我想要得到的http://example.com/login
当我使用Python的LXML和评估的表达,它工作正常。
你试过'$ node-> getAttribute('href');'? –
它什么都不打印 – user3869692
如果' - > nodeValue'给你“登录”,那么' - > getAttribute('href')'肯定会给你上面的URL。 –