Created
October 7, 2012 14:27
-
-
Save jefferyto/3848531 to your computer and use it in GitHub Desktop.
Open Data table to run a query and stringify its return value
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> | |
<author>Jeffery To</author> | |
<description>Open Data table to run a query and stringify its return value</description> | |
<sampleQuery>select * from {table} where query='select * from html where url="http://www.yahoo.com/"' and xpath='//a'</sampleQuery> | |
</meta> | |
<bindings> | |
<select itemPath="" produces="XML"> | |
<urls> | |
<url></url> | |
</urls> | |
<inputs> | |
<key id="query" type="xs:string" paramType="variable" required="true" /> | |
<key id="xpath" type="xs:string" paramType="variable" required="false" /> | |
</inputs> | |
<execute><![CDATA[ | |
var q = y.query(query), results = q.results; | |
if (xpath) { | |
results = y.xpath(results, xpath); | |
} | |
response.object = results.toXMLString(); | |
]]></execute> | |
</select> | |
</bindings> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment