The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

rstein (5) [Avatar] Offline
#1
I would like to develop an Ajax application that will use XSLT to translate and XML datafeed into HTML. I wrote the XSL and XML documents and proved that they work using an <iframe> element. I then moved on to implement the code in "Ajax in Action" page 482.

This works perfectly in a Firefox browser, but fails in IE. After much digging around I discovered that the following javascript:

alert ( this.req.responseXML.documentElement ) returns null in IE but returns "object [element]" in firefox which tells me that responseXML is not a valid XML document. This happens with both the XML data file as well as the XSL file. The 'responseText' property returns the correct XML text in both browsers.

A short example of my XML data file follows:

<?xml version="1.0"?>
<buttonMenu>
<buttonName command="ack">
Acknowledge
</buttonName>
<buttonName command="clo">
Close
</buttonName>
<buttonName command="xfr">
Transfer
</buttonName>
<buttonMenu>

I found another post on this board from 2005 with similar issues but no resolution. I would like to have this work in both browsers.
Pascarello (208) [Avatar] Offline
#2
Re: XML Problems with IE
rstein (5) [Avatar] Offline
#3
Re: XML Problems with IE
I have already looked at this page. My best guess is that my content type is not being set. I am currently working with a text file (will move to 'cgi' in the future). Is there some sort of header I need to add to this file? I have tried the following:

<?xml version="1.0" content="text/xml"?>
<meta http-equiv="content-type" content="text/xml; charset=ISO-8859-1" />

With no luck. Perhaps I can't do this with a simple text file?

I am using net.ContentLoader from Chapter 12 of the book.
Pascarello (208) [Avatar] Offline
#4
Re: XML Problems with IE
if the extension .xml for the file?

Can you open the XML file directly in IE without any problems?

Eric
Pascarello (208) [Avatar] Offline
#5
Re: XML Problems with IE
The reason I say this is that little sample code you gave should say something like:

The following tags were not closed: buttonMenu, buttonMenu. Error processing resource '...

Eric
rstein (5) [Avatar] Offline
#6
Re: XML Problems with IE
Thank You for your quick reply's. The sample code in my first post has a typo in the last buttonMenu. It is correct in the actual file. The file has an .xml extension and it displays fine in IE.
Pascarello (208) [Avatar] Offline
#7
Re: XML Problems with IE
When you do an alert with the responseText do you see the whole file? I am just poking around hoping to discover something...lol

You running this on the file system or some sort of server?

Eric
rstein (5) [Avatar] Offline
#8
Re: XML Problems with IE
I decided to approch this problem from a different angle. I wrote a simple 'cgi' application (in c) that does nothing more than printf "content-type: text/xml

" and then dump my xml file. I copied this to my web server and used the url in the call to net.ContentLoader() with a method of "POST". This works perfectly.

Perhaps IE will not work with a "GET" for a static file (firefox works fine)?
Pascarello (208) [Avatar] Offline
#9
Re: XML Problems with IE
IE works fine with a static file. I use static files all the time in my examples when I do talks.

For some reason it has to be thinking it is not a valid xml doc, rather strange since normally opening it directly tells you that. Maybe whitespace? I have no other idea what could be wrong!


Eric
kurinosuke (156) [Avatar] Offline
#10
Re: XML Problems with IE
Sorry, please forget this message... I didn't notice that the following has already been pointed out.

---DEL---
In your first post, the buttonMenu tag is not closed.
rstein (5) [Avatar] Offline
#11
Re: XML Problems with IE
Up to this point I have been working on all code on my desktop, using your wonderful book to teach myself the technology. Everything has worked up to this point.

I moved everything to a test server and now it all works. Firefox works fine through the desktop and server. IE's ActiveX only seems to work through a server.