标题比它必须的更复杂,这是问题查询。
SELECT *
FROM query.multi
WHERE queries="
SELECT *
FROM html
WHERE url='http://www.stumbleupon.com/url/http://www.guildwars2.com'
AND xpath='//li[@class=\"listLi\"]/div[@class=\"views\"]/a/span';
SELECT *
FROM xml
WHERE url='http://services.digg.com/1.0/endpoint?method=story.getAll&link=http://www.guildwars2.com';
SELECT *
FROM json
WHERE url='http://api.tweetmeme.com/url_info.json?url=http://www.guildwars2.com';
SELECT *
FROM xml
WHERE url='http://api.facebook.com/restserver.php?method=links.getStats&urls=http://www.guildwars2.com';
SELECT *
FROM json
WHERE url='http://www.reddit.com/button_info.json?url=http://www.guildwars2.com'"
具体来说这条线,
xpath='//li[@class=\"listLi\"]/div[@class=\"views\"]/a/span'
由于引用而出现问题,我必须将它们嵌套三层深,并且我已经用完了可以使用的引号字符。我尝试了以下变体但没有成功:
//no attribute quoting
xpath='//li[@class=listLi]/div[@class=views]/a/span'
//try to quote attribute w/ backslash & single quote
xpath='//li[@class=\'listLi\']/div[@class=\'views\']/a/span'
//try to quote attribute w/ backslash & double quote
xpath='//li[@class=\"listLi\"]/div[@class=\"views\"]/a/span'
//try to quote attribute with double single quotes, like SQL
xpath='//li[@class=''listLi'']/div[@class=''views'']/a/span'
//try to quote attribute with double double quotes, like SQL
xpath='//li[@class=""listLi""]/div[@class=""views""]/a/span'
//try to quote attribute with quote entities
xpath='//li[@class="listLi"]/div[@class="views"]/a/span'
//try to surround XPath with backslash & double quote
xpath=\"//li[@class='listLi']/div[@class='views']/a/span\"
//try to surround XPath with double double quote
xpath=""//li[@class='listLi']/div[@class='views']/a/span""
一切都没有成功。
我没有看到太多关于转义 XPath 字符串的内容,但我发现的所有内容似乎都是使用 concat (这不会有帮助,因为 ' 和 " 都不可用)或 html 实体的变体。不使用属性的引号不会不会抛出错误但会失败,因为它不是我需要的实际 XPath 字符串。
我在 YQL 文档中没有看到任何有关如何处理转义的内容。我知道这有多么边缘化,但希望他们能有某种逃生指南。
您需要转义任何分隔 XPath 查询的字符双反斜杠... 换句话说:
SELECT * FROM query.multi
WHERE queries="
SELECT *
FROM html
WHERE url='http://www.stumbleupon.com/url/http://www.guildwars2.com'
AND xpath='//li[@class=\\'listLi\\']/div[@class=\\'views\\']/a/span';
SELECT *
FROM xml
WHERE url='http://services.digg.com/1.0/endpoint?method=story.getAll&link=http://www.guildwars2.com';
SELECT *
FROM json
WHERE url='http://api.tweetmeme.com/url_info.json?url=http://www.guildwars2.com';
SELECT *
FROM xml
WHERE url='http://api.facebook.com/restserver.php?method=links.getStats&urls=http://www.guildwars2.com';
SELECT *
FROM json
WHERE url='http://www.reddit.com/button_info.json?url=http://www.guildwars2.com'"
(try this in the YQL console http://y.ahoo.it/4aEf5pEO)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)