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.
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.
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) > 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.
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
Perhaphs this project will help you?
http://our.umbraco.org/projects/feed-cache
Peter
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
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:
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.
is working on a reply...