XMLDocument and XMLHttpRequest ?

J

Jarod

Hey
I have something like this:
var xmlDoc=document.implementation.createDocument("", "", null);

but in opera xmlDoc.load(...) won't work, so I use:

XMLHttpRequest, and I have all needed code... let's say it works...

So I got serviceRequest.responseXML and is there a way to initialize xmlDoc
in my case ? I am asking because I have code that uses xmlDoc.load(...) in
FF and all code that's need to futher work with XML written. So this would
be comfortable for me to use xmlDoc instead of creating everything from
start.
Jarod
 
M

Martin Honnen

Jarod wrote:

I have something like this:
var xmlDoc=document.implementation.createDocument("", "", null);

but in opera xmlDoc.load(...) won't work, so I use:

XMLHttpRequest, and I have all needed code... let's say it works...

So I got serviceRequest.responseXML and is there a way to initialize
xmlDoc in my case ?

How about
var xmlDoc = serviceRequest.responseXML;
Of course you have to put that in the onreadystatechange event handler
at the proper place after a check of e.g.
if (serviceRequest.readyState == 4)
and perhaps further checks of the HTTP status code. But once you have
responseXML you can use that as your XML document.
 
V

VK

Martin said:
Jarod wrote:



How about
var xmlDoc = serviceRequest.responseXML;
Of course you have to put that in the onreadystatechange event handler
at the proper place after a check of e.g.
if (serviceRequest.readyState == 4)
and perhaps further checks of the HTTP status code. But once you have
responseXML you can use that as your XML document.

And of course your server has to send *.xml files with text/xml content
header otherwise this bird won't fly (AJAX still doesn't respect file
extensions and your responseXML will contain an empty string).
 
J

james.r.carr

VK said:
And of course your server has to send *.xml files with text/xml content
header otherwise this bird won't fly (AJAX still doesn't respect file
extensions and your responseXML will contain an empty string).

It is my experience that you are safest sending the Content-Type as
application/xml rather than text/xml.
 
T

Thomas 'PointedEars' Lahn

VK said:
And of course your server has to send *.xml files with text/xml
content [...] (AJAX still doesn't respect file extensions

First, there is no such thing as AJAX being a defined application framework
or something, so it does not make sense to state "AJAX does/not support
this or that". Second, I hope "it" never will support that: "File
extensions" are merely a Micro$~1 means to mask their ongoing inability
to support MIME/magic properly and consequently. "File extensions" do not
belong on today's Web.

<URL:http://www.w3.org/QA/Tips/uri-choose> et seq.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top