问题
YQL gives out result only in tree view. Is there any way to get the result in Formatted view??
回答1:
Use an XSLT stylesheet to create a formatted view. Here is an example for an RSS feed:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="XML" encoding="utf-8"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system=http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
indent="yes"/>
<xsl:template match='//channel'>
<page>
<content>
<module>
<header layout="simple">
<layout-items>
<block class="title">YDN Widget</block>
</layout-items>
</header>
</module>
<xsl:apply-templates select="item" />
</content>
</page>
</xsl:template>
<xsl:template match="item">
<placard layout="card" class="link">
<layout-items>
<image resource="ybang"/>
<block class="title"><xsl:value-of select="title"/></block>
<block class="description"><xsl:value-of select="pubDate"/></block>
<block class="subtext"><xsl:value-of select="category"/></block>
</layout-items>
<load resource="{link}" event="activate"/>
</placard>
</xsl:template>
</xsl:stylesheet>
Referenced using the following YQL syntax:
select * from xslt where url="//foo.rss" and stylesheet="//bar.xsl"
来源:https://stackoverflow.com/questions/2588736/how-to-get-the-formatted-view-of-yql-as-result