Archive for category XPath

RSS XSLT

Simple piece of XSL to format 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="html"></xsl:output>
    <xsl:template match="rss/channel/item">
    <li>
      <a href="{link}" title="{title}">
        <xsl:value-of select="title" />
      </a>
      <p>
        <xsl:value-of select="description" />
      </p>
    </li>
  </xsl:template>
</xsl:stylesheet>

No Comments

Consuming RSS Feeds using ASP.net controls

Real simple example, using an XmlDataSource and my new super best friend, the ListView control;

    <asp:ListView ID="RSSList" runat="server" DataSourceID="RSSData">
        <LayoutTemplate>
            <ul>
                <li id="itemPlaceholder" runat="server" />
            </ul>
        </LayoutTemplate>
        <ItemTemplate>
            <li><h2>
                <%#XPath("title") %>
            </h2>
            
            <%#XPath("author") %>
            <a href='<%#XPath("link") %>' title=''>View Original Post</a>
            </li>
        </ItemTemplate>
    </asp:ListView>
    <asp:XmlDataSource 
        ID="RSSData" 
        runat="server" 
        DataFile="http://www.shawson.co.uk/codeblog/feed/"
        XPath="rss/channel/item">
    </asp:XmlDataSource>

No Comments

Visually build XPath using “Sketch Path”

Paul found an awesome tool fopr visually parsing XML files and building XPath statements, called Sketch Path available for download here

No Comments