Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kris Dyson 54 posts 79 karma points
    Mar 18, 2010 @ 14:47
    Kris Dyson
    0

    GetXmlDocumentByUrl error

    Hi there, we're reading and combining lots of RSS feeds and sometimes it may be the case that that feed may not be available for one reason or other... e.g., the external server could be down or feed corrupted.

    Is there any way I can get XSLT to ignore errors from GetXmlDocumentByUrl?  or maybe I should write an XSLTExtension and ignore the error publicly and then silently report it to admin in the background?

    Probably the latter option is best - but it'd be good to know if there was a way ignore this error with pure xslt.

    thanks

    Kris 

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Mar 18, 2010 @ 14:52
    Peter Dijksterhuis
    2

    Perhaphs this project will help you? 

    http://our.umbraco.org/projects/feed-cache

    Peter

  • Kris Dyson 54 posts 79 karma points
    Mar 18, 2010 @ 15:18
    Kris Dyson
    0

    hi Peter, thanks for that - although I think I'm probably going to do an XSLT extension as well, because I cannot really trust external content will be well-formed XML etc.

     thanks!

    k

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 18, 2010 @ 16:29
    Lee Kelleher
    1

    Hi Kristan,

    Have you looked at the code for GetXmlDocumentByUrl? (I use .NET Reflector, but feel free to check the core source)

    If there is an exception with the XML request, an <error /> XML node is returned. So you could have the following:

    <xsl:variable name="feed" select="umbraco.library:GetXmlDocumentByUrl('http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml')" />
    <xsl:choose>
        <xsl:when test="count($feed/error) &gt; 0">
            <!-- do what you like with the error ... params: error/@url, error -->
        </xsl:when>
        <xsl:otherwise>
            <xsl:apply-templates select="$feed" />
        </xsl:otherwise>
    </xsl:choose>

    As Peter mentioned Feed Cache is pretty useful ... I personally don't use it, found it overkill for my needs - but each to their own.

    Cheers, Lee.

Please Sign in or register to post replies

Write your reply to:

Draft