<xsl:template match="/"> <xsl:choose> <xsl:when test="$feed != ''"> <xsl:variable name="feedContent" select="umbraco.library:GetXmlDocumentByUrl($feed, 3600)"/> <xsl:choose> <xsl:when test="$feedContent != 'error'"> <xsl:call-template name="renderFeed"> <xsl:with-param name="feedContent" select="$feedContent"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <p><strong>Feed Viewer Macro Error: Error fetching feed</strong><br />The feed '<xsl:value-of select="$feed"/>' could not be loaded. Verify that the feed url exists and that you have anactive internet connection</p> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <p><strong>Feed Viewer Macro Error: No feed chosen</strong><br />Please make sure to add a value in the "Feed Url" parameter </p> </xsl:otherwise> </xsl:choose> </xsl:template>
System.Xml.XmlException: '', hexadecimal value 0x1F, is an invalid character. Line 1, position 91. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args) at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars) at System.Xml.XmlTextReaderImpl.ParseText() at System.Xml.XmlTextReaderImpl.ParseElementContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace) at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at System.Xml.XmlDocument.LoadXml(String xml) at umbraco.library.GetXmlDocumentByUrl(String Url) at umbraco.library.GetXmlDocumentByUrl(String Url, Int32 CacheInSeconds)
I don't know how to fix this for you, but I think I know what's happening - the server is Gzip'ing the response (even though it's not requested to) - browsers handle this transparently to us, but apparently the underlying .NET frameworks don't :-(
RSS feed URL cause error
Hi
I'm working with a feed from Trustpilot, I want to create a custom view of the costumers reviews. I'm creating the xslt out of this post.
But when I insert the URL for the feed I get this error:
I have discovered that if I remove the first dot in the URL I don't get an error, but then the link isn't correct so that really dosen't help me.
I'm using Umbraco v 4.5.2.
Any help will be appreciated!
Hi Kasper,
Looks like an error in the feed (or maybe a pasted character in the stylesheet?)
Try these:
1. Can you open the feed URL in a browser?
2. Can you open the XSLT file in Internet Explorer?
/Chriztian
Hi Chriztian
1: Yes.
2: If you by that mean paste the direct url for the xslt file in IE, then yes.
OK - great; If you can open both the feed XML and the XSLT as plain XML files, it's not a cut 'n paste error.
Then it's bound to be something that happens during the processing - are you doing any Replace stuff, Date conversion etc.?
Maybe paste some of the code?
/Chriztian
Note: I have now inserted a namespace that Trustpilot uses in the rss feed. But it makes no difference to this issue.
xmlns:tp="http://www.trustpilot.dk/rss/"
<xsl:param name="currentPage"/>
<xsl:variable name="numberOfItems" select="10" />
<xsl:variable name="excerptLength" select="200" />
<xsl:variable name="feed" select="string('http://trustbox.trustpilot.com/r/example.com.xml')"/>
<xsl:template match="/">
<xsl:choose>
<xsl:when test="$feed != ''">
<xsl:variable name="feedContent" select="umbraco.library:GetXmlDocumentByUrl($feed, 3600)"/>
<xsl:choose>
<xsl:when test="$feedContent != 'error'">
<xsl:call-template name="renderFeed">
<xsl:with-param name="feedContent" select="$feedContent"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<p><strong>Feed Viewer Macro Error: Error fetching feed</strong><br />The feed '<xsl:value-of select="$feed"/>' could not be loaded. Verify that the feed url exists and that you have anactive internet connection</p>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<p><strong>Feed Viewer Macro Error: No feed chosen</strong><br />Please make sure to add a value in the "Feed Url" parameter
</p>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="renderFeed">
<xsl:param name="feedContent"/>
<xsl:if test="count($feedContent//item) > 0">
<ul class="feedList">
<xsl:for-each select="$feedContent//item">
<xsl:if test="position() <= $numberOfItems">
<li>
<small><xsl:value-of select="umbraco.library:LongDate(pubDate)"/></small>
<h4><a href="{link}"><xsl:value-of select="title" disable-output-escaping="yes"/></a>
</h4>
<xsl:choose>
<xsl:when test="string($excerptLength) != '0'">
<p>
<xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(description), number($excerptLength), '...')" disable-output-escaping="yes"/>
</p>
</xsl:when>
<xsl:otherwise>
<!-- <xsl:value-of select="description" disable-output-escaping="yes"/> -->
</xsl:otherwise>
</xsl:choose>
</li>
</xsl:if>
</xsl:for-each>
<li class="last"><xsl:text disable-output-escaping="yes">&</xsl:text>nbsp;</li>
</ul>
</xsl:if>
</xsl:template>
- Can you see from the trace, which method ends up throwing the exception?
/Chriztian
It's definitely the XML from the feed that's causing this (or Umbraco's way of loading it, at least...)
Try swapping the GetXmlDocumentByUrl() function with the native document() function and see if that is able to load the file:
/Chriztian
:( No, it's the same
Hi Kasper,
I don't know how to fix this for you, but I think I know what's happening - the server is Gzip'ing the response (even though it's not requested to) - browsers handle this transparently to us, but apparently the underlying .NET frameworks don't :-(
/Chriztian
Okay. Well, thanks for the explanation and the help so far. I'll post again if a solution turns up.
OK, with a little help from @leekelleher, here's a link to some information which might help:
http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream(v=vs.90).aspx#11
Though, as I see it, you'll probably need to create an extension to handle it...
/Chriztian
I've added a new method to uComponents that should be able to handle this. I haven't tested it extensively, but should work (fingers crossed).
You'll need to download and compile the latest source, (or wait until the next release of uComponents - which might be another week away yet)
http://ucomponents.codeplex.com/SourceControl/changeset/changes/84974
In the XML extension, the method is called "GetXmlDocumentByUrl", with an extra parameter for specifying whether to check for GZipped data.
Good luck!
Cheers, Lee.
Waow. Thanks a lot guys! Unfortunately we are now moving in to an area where I might need to contact the IT department :-/
Thanks again. I'll let you know how it turns out.
If any other people has ideas you're welcome to post them :-)
Okay here is an unecspected turn...
Trustpilot has just made a new way to get data from them: JSON
Not that I'm an expert in JSON, but thougt it was a good alternative. Can XSLT an JSON work together?
XSLT isn't built for string parsing, and has no native ability to parse JSON. You'd need some way to convert the JSON to XML first.
If that proves to be necessary, and if you're comfortable depending on a third-party service, I've found YQL to be perfect for that:
http://developer.yahoo.com/yql/console/#h=select%20*%20from%20json%20where%20url%3D%22http%3A//pipes.yahoo.com/pipes/pipes.popular%3F_out%3Djson%22%20and%20itemPath%20%3D%20%22value.items%22
You'll probably want to cache the output with Darren Ferguson's FeedCache package, I'd imaginge.
Thanks for the tip Dan
is working on a reply...