473,383 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

XMLDocument and XMLHttpRequest ?

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

Dec 29 '05 #1
4 2507


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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 29 '05 #2
VK

Martin Honnen wrote:
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.


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).

Dec 29 '05 #3
VK wrote:
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.

Dec 29 '05 #4
VK wrote:
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
Dec 30 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: brad | last post by:
I have an XMLDocument that my web page downloads and manipulates as a response to user input. I have lots of JavaScript that acts as a controller between my view (html) and my model (xml). That...
10
by: Matt Kruse | last post by:
I'm aware of the circular reference memory leak problem with IE/closures. I'm not sure exactly how to resolve it in this situation. Also, Firefox appears to grow its memory size with the same code....
21
by: Joe Attardi | last post by:
Hey all! I was reading over at the IE Blog the other day http://http://blogs.msdn.com/ie/] and read some interesting, and encouraging news. According to Sunava Dutta, an IE Program Manager,...
13
by: TLaufenberg | last post by:
I'm new to Javascript programming and I've run into a bit of a snag with making an XMLHttpRequest in the Safari browser. Actually, the request doesn't work in Firefox either but only when I use a...
5
by: Peter Michaux | last post by:
Hi, The FAQ correctly says the following: "Mozilla (NN6.2+, Firefox, Ice Weasle etc), Opera 7.6+, Safari1.2+, the Windows version of IE versions 5+, and some other browsers provide the XML...
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
1
by: Tarik Monem | last post by:
OK, I'm pretty sure this cannot work because I'm trying to use JavaScript (client-side) to write to an xml file (which is server-side) using XMLHttpRequest. Can I use PHP do what I'm trying to do?...
6
by: Patrick Nolan | last post by:
I'm working on cross-platform portability of some javascript. My Macintosh testing platform is rather old. It has Safari 1.3.2 and Internet Explorer 5.2. I got Safari working, but now IE is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.