在尝试使用Yahoo Query Language和YQL提供的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
时给了我相同的结果