We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
文档里的例子如下:
$html =<<<STR <div id="demo"> <span class="tt">bbb</span> <span>ccc</span> <p rel="pnode">ddd</p> </div> STR;
//获取id为demo的div内容 $data = selector::select($html, "//div[@id='demo']");
print_r($data),运行结果是:
<span class="tt">bbb</span> <span>ccc</span> <p rel="pnode">ddd</p>
// 获取class为tt的span内容 $data = selector::select($html, "//div[@class='tt']");
//div[@class='tt']
print_r($data),运行结果是空的,啥都打印不出来
// 获取rel为pnode的p内容 $data = selector::select($html, "//div[@rel='pnode']");
//div[@rel='pnode']
另外一个例子:
$html =<<<STR <td data-value="3.80">3.80</td> <td data-value="3.80">3.80</td> <td data-value="3.80">3.80</td> <td data-value="3.80">3.80</td> STR;
// 获取 td 的 data-value 属性 $data = selector::select($html, "//td@data-value");
为什么会这样呢,是php配置需要修改吗,还是其他什么原因呢?麻烦您能帮我解答一下吗,非常感谢。
The text was updated successfully, but these errors were encountered:
$html =<<<STR <td data-value="3.80">3.80</td> <td data-value="3.80">3.80</td> <td data-value="3.80">3.80</td> <td data-value="3.80">3.80</td> STR; // 获取 td 的 data-value 属性 $data = selector::select($html, "//td@data-value");
这个打印selector::$error,显示的是xpath语法错误 @owner888 是森么问题导致的 ?这个xpath应该没写错啊
Sorry, something went wrong.
// 获取 td 的 data-value 属性 文档的这个$data = selector::select($html, "//td@data-value");写法错误
$data = selector::select($html, "//td@data-value");
正确写法为$data = selector::select($html, "//td/@data-value");
$data = selector::select($html, "//td/@data-value");
@kekeyumuku @owner888 @awebc
感谢支持,我去改过来
No branches or pull requests
文档里的例子如下:
//获取id为demo的div内容
$data = selector::select($html, "//div[@id='demo']");
print_r($data),运行结果是:
// 获取class为tt的span内容
$data = selector::select($html, "
//div[@class='tt']
");print_r($data),运行结果是空的,啥都打印不出来
// 获取rel为pnode的p内容
$data = selector::select($html, "
//div[@rel='pnode']
");print_r($data),运行结果是空的,啥都打印不出来
另外一个例子:
// 获取 td 的 data-value 属性
$data = selector::select($html, "//td@data-value");
print_r($data),运行结果是空的,啥都打印不出来
为什么会这样呢,是php配置需要修改吗,还是其他什么原因呢?麻烦您能帮我解答一下吗,非常感谢。
The text was updated successfully, but these errors were encountered: