Jon Barnett

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromJon Barnett
ToMe
SubjectimportXML issue in Mozilla.
Date12 November 2004 9:24
My company develops a content management system, and as the customer
support person, I have no access to PHP scripts of my own (unless I write
one and ask nicely for the programmers to upload it for me).  However, I
did write a short PHP script that can be sent an absolute URL through a
querystring that will basically echo out the contents of the URL.  I'm
trying to use this short PHP script to load the contents of any RSS feed on
the web, and then run script on that RSS feed.  After I get the bugs worked
out, I do not plan to 'illegally' use other sites' RSS, but in the working
progress, I am trying to use a random RSS feed I found.
 
My testing page is located here: [test page address]
 
If you dig past all the page layout stuff in the content management system,
you'll reach my <script> tag that includes your importXML function, a call
to it, and a short function that will alert() the number of 'item' tags in
the XML - function populate(mydoc).  Internet Explorer has no trouble
alerting that there are '7' item tags in the XML.  Firefox (Mozilla) fails
to alert anything, which leads me to assume that function populate never
gets called.  If you get a chance, please help me determine why this is. 
 
Thanks,
 
Jon Barnett
FromMe
ToJon Barnett
SubjectRe: importXML issue in Mozilla.
Date16 November 2004 9:00
Jon,

a quick look at the Mozilla JavaScript console shows the error:
Error: mydoc has no properties
Line: 600

So it is calling the function but not getting anywhere with it. It seems
that Mozilla is loading the page, but the page it gets is being treated as
being blank.

Interestingly, it also works perfectly in Opera 7.6, which uses the same
constructor as Mozilla.

The problems are as follows:
Your PHP file sends the wrong content type header.
Your PHP file does not send the content length header.

Mozilla expects to be given the text/xml Content-type, and for IE, when
you use the text/xml header, you should also provide the content-length
header.

header('Content-Type: text/xml');
header('Content-Length: '.strlen($contents));

My rssLocal.php script already includes these (as well as some infinite
loop server protection stuff), and can be downloaded as part of the zip
package from:
http://www.howtocreate.co.uk/tutorials/jsexamples/rss.html 

Hope this helps

Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.