Email conversation
From | Jesse Cleary-Budge |
To | Me |
Subject | Atom Parser ASP Help |
Date | 4 February 2009 22:22 |
Hello Tarquin,
First off, thanks a lot for the scripts you provide on your site. I'm
attempting to use the Atom/RSS Javascript parser with ASP instead of PHP. I
read through all the Atom parser emails, and have tried to implement this
code on the site <[URL]> I'm designing:
<script type="text/javascript">
var URL = '[URL]';
window.onload = function () {
importXML('rssLocal.asp?feedURL='+escape(URL),'parseRSS',false,5000);
};
</script>
You can see the Atom feed URL from blogspot that I entered as the URL var. I
inserted this code inside a HTML <div> element, but nothing is displaying. I
am not an experienced JavaScript user, but I do have experience coding in
other languages and using HTML. Do you have any insight? Thanks a lot!
Regards,
Jesse Cleary-Budge
From | Me |
To | Jesse Cleary-Budge |
Subject | Re: Atom Parser ASP Help |
Date | 7 February 2009 08:45 |
Jesse,
> tried to implement this code on the site I'm designing:
>
> <script type="text/javascript">
> var URL = 'http://ormondepedigrees.blogspot.com/atom.xml';
> window.onload = function () {
> importXML('rssLocal.asp?feedURL='+escape(URL),'parseRSS',false,5000);
> };
> </script>
This is the only script you have on the page. You are missing the two other
scripts that it needs in order to run. Basically, you are telling it to run
my script, but my script isn't actually there in order for it to run.
Take a look in the file 'normal/rss.html' in the package you downloaded.
There are two scripts right at the start in the page HEAD; one referenced
externally, and one inside the page itself. You are missing both of those.
You are also missing the DIV where the script will output the feed content
(the ID is important):
<div id="feedcontainer"></div>
Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
From | Jesse Cleary-Budge |
To | Me |
Subject | Re: Atom Parser ASP Help |
Date | 11 February 2009 18:12 |
Tarquin,
Thank you very much for your reply. I have now implemented the feed-reader
on the following site:
[URL]
The problem I am encountering is that the feed is only displayed on Google
Chrome out of the browsers I am able to test at the moment (Firefox 3, IE 7,
and Chrome 1.0). When I test the site on IE 7, a Javascript error appears
that the feed cannot be displayed properly. No error displays on Firefox.
Everything displays as desired on Chrome. Do you have any insight?
Also, I would like to limit the feed-reader to only display one post. Is
there a simple way to implement that change? Thanks a lot.
Regards,
Jesse Cleary-Budge
From | Me |
To | Jesse Cleary-Budge |
Subject | Re: Atom Parser ASP Help |
Date | 14 February 2009 08:16 |
Jesse,
> The problem I am encountering is that the feed is only displayed on Google
> Chrome out of the browsers I am able to test at the moment (Firefox 3, IE 7,
> and Chrome 1.0)
In future, please also give results for Opera:
http://www.opera.com/download/
> When I test the site on IE 7, a Javascript error appears
> that the feed cannot be displayed properly. No error displays on Firefox.
You're not the first person to have this problem:
http://www.howtocreate.co.uk/emails/AnthonyGasparich.html
The feed contains quote characters that offend ASP. Even though what it
read was perfectly valid in utf-8 encoding, ASP chooses to output in (I
think) 8859-1 encoding. The output contains the XML prologue that says
it is utf-8, but it's not actually utf-8 that's coming out of it. As a
result, IE and Firefox choke when they see those characters, which are
now valid quote characters in in 8859-1, but are not valid byte
sequences in utf-8.
Opera and Safari/Chrome manage to recover, IE and Firefox cannot.
Since ASP insists on breaking the encoding, I suggest you just remove
those quote characters from the blog post, and replace them with normal
quotes. The existing ones are the ones that look like this: “” and the
normal ones look like this: ""
> Also, I would like to limit the feed-reader to only display one post. Is
> there a simple way to implement that change? Thanks a lot.
This shows how to do it (the example shows how to do it for 2 items, but
you can just change it as needed to make it only give one item):
http://www.howtocreate.co.uk/emails/AlIngham.html
From | Jesse Cleary-Budge |
To | Me |
Subject | Re: Atom Parser ASP Help |
Date | 16 February 2009 17:09 |
Tarquin,
Thanks again for all your help. I have downloaded Opera and will use
it when testing.
I took care of the offending quotes in the blog post, and that
immediately fixed the problem in IE; the feed displays correctly in
Opera 9.6, IE 7, and Chrome 1.0. The blog feed still does not appear
in Firefox, however. I poked around the emails you sent, and I did
implement the single blog post limitation. Additionally, I tried the
RSS 0.91 fix that you suggested to the person having the same ASP
conflict. This did not affect Firefox's performance at all. I left the
RSS fix implemented; the feed script is being implemented at this
site:
[URL]
It seems there are more problems with Firefox's interpretation of the
code. Could there be other characters that Firefox is not interpreting
correctly from the XML through ASP? Please let me know if you have any
more insight. Thanks a lot!
Regards,
Jesse
From | Me |
To | Jesse Cleary-Budge |
Subject | Re: Atom Parser ASP Help |
Date | 17 February 2009 10:28 |
Jesse,
> the feed displays correctly in
> Opera 9.6, IE 7, and Chrome 1.0. The blog feed still does not appear
> in Firefox, however.
This is a bug I have not seen before. The rssLocal.asp adds the correct
Content-Length header. Your server then thinks it has not been added, so it
calculates the content length. Then it realises the header already exists,
but instead of intelligently checking if it is correct and leaving it alone,
it appends its calculated value to the end of the existing value. So instead
of this valid header:
Content-Length: 6669
It is sending this invalid header:
Content-Length: 6669,6669
Almost all browsers handle this just fine, and will ignore the second value.
Firefox, however, goes crazy. Firstly it hangs up the connection for a
while, without accepting the response (presumably waiting for a second
response). Then after a while, it requests the URL again. By this stage, it
has broken the XMLHttpRequest response, so the script does not run.
The trouble is that the Content-Length header is needed, or it will not work
in IE. Also, it seems that IIS will not always provide that header, so I
guess it depends on the server. I'm afraid I do not know ASP well enough to
come up with a generic solution to preventing servers from corrupting the
headers like this, so it will have to remain as a manual task to prevent it.
Since it seems your server is trying to add the header, it may well work
without the script explicitly trying to set it. Try commenting out these two
lines:
Response.AddHeader "Content-Length",len(RSSXML)
and
Response.AddHeader "Content-Length","562"
If it then works in everything, then great. If not, I am afraid you will
need to ask some ASP experts for help on preventing your server from
corrupting the header.
From | Jesse Cleary-Budge |
To | Me |
Subject | Re: Atom Parser ASP Help |
Date | 17 February 2009 15:42 |
Tarquin,
Yes! It worked! I commented out the ASP header lines and now the blog feed
works in Firefox as well as the other modern browsers! Thanks a million for
your help.
One last question: your Javascript has a line that sets document.title:
//now that the entire feed has been converted into JavaScript arrays, it is
//time to write it out
document.title = feedInfo['title'] ? ( 'News Feed: ' + feedInfo['title'] ) :
'Untitled newsfeed';
This line, however, dynamically changes the HTML title to (in this case)
"News Feed: [feed title]", which is undesirable. I have tried putting
the HTML title tag so it will come after the Javascript, but it is still
overridden. Also I have tried adding <script> document.title = 'Ormonde
Pedigrees' </script> to the head element, but this did not work either. Do
you have a solution?
This should be the last step in my journey to get a dynamic blog feed on
this site. Your code and help have been invaluable. Thank you so much.
Regards,
Jesse
From | Me |
To | Jesse Cleary-Budge |
Subject | Re: Atom Parser ASP Help |
Date | 19 February 2009 15:48 |
Jesse,
> Yes! It worked! I commented out the ASP header lines and now the blog feed
> works in Firefox as well as the other modern browsers!
Good to know.
By the way, I think I found an even better solution which should work on all
ASP servers, whether they are configured to send the content-length header
(like yours) or not. It seems all I have to do is disable response buffering
- then the server will not know the response length, and will not add the
header. All that needs to be done is to add this at the start of the ASP
file:
Response.Buffer = false
just before this line:
feedURL = request("feedURL")
Could you give that a try (and re-enable those two lines that you commented
out), and let me know if it works in all the browsers? It seems to work in
my tests, but I don't have a proper production server to test on.
I will then update the documentation or passthru script accordingly.
[Ed. The currently downloadable version of the script already uses this.]
> document.title = [etc.]
The reason this manages to avoid your attempts to prevent it is because it
runs much later - after the document has loaded.
If you don't want it to change the title, just comment out the line;
put // in front of it.