Problems using DOM on an XML document

A

a

Hi everybody,

I am using AJAX to request an XML doc from the server.

I get it and it's well formed - I test it with:

alert( req.responseText );

then I try to access the various elements in the document and I start at the
root:

var xml_doc = req.responseXML;
var root_node = xml_doc.documentElement;

xml_doc is a valid object, but root_node is null. I tried with other dom
methods:
getElementsByTagName( 'root' )[ 0 ] etc, but the root_node var is always
null.

I am testing this on IE 6.

Any ideas what causes this?

Thanks,

A
 
A

a

I added this line on the server side:
<?php
header('Content-Type: text/xml');
....
?>

and that solved the problem.

A
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top