Created
February 14, 2011 14:57
-
-
Save cheeaun/825981 to your computer and use it in GitHub Desktop.
Updated version of data.html.cssselect Open Data Table for YQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" ?> | |
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> | |
<meta> | |
<sampleQuery>select * from {table} where url="www.yahoo.com" and css="#news a"</sampleQuery> | |
</meta> | |
<bindings> | |
<select itemPath="" produces="XML"> | |
<urls> | |
<url></url> | |
</urls> | |
<inputs> | |
<key id="url" type="xs:string" paramType="variable" required="true" /> | |
<key id="css" type="xs:string" paramType="variable" /> | |
</inputs> | |
<execute><![CDATA[ | |
//include css to xpath convert function | |
y.include("http://css2xpath.googlecode.com/files/css2xpath.min.js"); | |
var query = null; | |
if (css) { | |
var xpath = css2xpath(css); | |
y.log("xpath "+xpath); | |
query = y.query("select * from html where url=@url and xpath=\""+xpath+"\"",{url:url}); | |
} else { | |
query = y.query("select * from html where url=@url",{url:url}); | |
} | |
response.object = query.results; | |
]]></execute> | |
</select> | |
</bindings> | |
</table> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment