在尝试使用 YQL 提供的 Yahoo Query Language 和 xpath 功能解析 html 时,我遇到了无法提取“text()”或属性值的问题。
例如
永久链接
select * from html where url="http://stackoverflow.com"
and xpath='//div/h3/a'
以 xml 形式给出锚点列表
<results>
<a class="question-hyperlink" href="/questions/661184/filling-the-text-area-with-the-text-when-a-button-is-clicked" title="In ASP.net, I need the code to fill the text area (in the form) when a button is clicked. Can you help me through by showing a simple .aspx code containing the script tag? ">Filling the text area with the text when a button is clicked</a>...
</results>
现在,当我尝试使用提取节点值时
select * from html where url="http://stackoverflow.com"
and xpath='//div/h3/a/text()'
我得到连接的结果而不是节点列表,例如
<results>Xcode: attaching to a remote process for debuggingWhy is b
…… </results>
如何将其分成节点列表以及如何选择属性值?
像这样的查询
select * from html where url="http://stackoverflow.com"
and xpath='//div/h3/a[@href]'
给了我相同的查询结果div/h3/a