Connecting Tech Pros Worldwide Forums | Help | Site Map

Problems using DOM on an XML document

a
Guest
 
Posts: n/a
#1: Jun 23 '06
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
Guest
 
Posts: n/a
#2: Jun 23 '06

re: Problems using DOM on an XML document


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

and that solved the problem.

A

"a" <xxxxxxx@pacbell.net> wrote in message
news:ejLmg.155770$F_3.36716@newssvr29.news.prodigy .net...[color=blue]
> 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
>
>
>
>
>[/color]


Closed Thread


Similar JavaScript / Ajax / DHTML bytes