Because that's not an xml document. By defining content-type: text/xml, you are telling any webbrowser to expect an xml document, and then not delivering one.
The sample code you've sent doesn't generate any output whatsoever, try it from the command line and see. Ross > -----Original Message----- > From: Baz Langton [mailto:[EMAIL PROTECTED]] > Sent: 21 August 2002 16:30 > To: [EMAIL PROTECTED] > Subject: Re: [PHP-WIN] Newbie: Setting content type > > > So why does the following code:- > > <?php > header("Content-type: text/xml "); > $doc = domxml_new_doc("1.0"); > $rootNode = $doc -> create_element("TEST"); > $NewNode = $doc -> append_child($rootNode); > ?> > > OR > > <?php > header("Content-type: text/xml "); > $doc = domxml_new_doc("1.0"); > $root = $doc->add_root("QUIZ"); > $NewNode = $doc -> append_child($rootNode); > ?> > > produce the following error:- > > The XML page cannot be displayed > Cannot view XML input using style sheet. Please correct the > error and then > click the Refresh button, or try again later. > > > ------------------------------------------------------------------ > ---------- > -- > > XML document must have a top level element. Error processing resource > 'http://localhost/php%20test/info.php'. > > > > > > > > > "Ross Fleming" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > There must be a problem in your xml code that you are generating then. > > > > header("Content-type: text/xml"); is indeed how you set the > content type > to > > an xml page, as your test shows. The problem being is that phpinfo() > > generates an html document, not an xml one. The error you got was > explorer > > telling you that it expected an xml doc but didn't receive one > > > > Ross > > > > > -----Original Message----- > > > From: Baz Langton [mailto:[EMAIL PROTECTED]] > > > Sent: 21 August 2002 16:13 > > > To: [EMAIL PROTECTED] > > > Subject: [PHP-WIN] Newbie: Setting content type > > > > > > > > > How do I set the content type to text/xml?? I have a small php > > > script which > > > queries a database and returns the results as an xml document. However > the > > > flash application is not parsing the xml correctly and I believe it is > > > because the response is in text/html. > > > > > > I've tired the following:- > > > > > > <?php header("Content-type: text/xml "); > > > phpinfo(); > > > ?> > > > > > > But this gives me the following error:- > > > > > > The XML page cannot be displayed > > > Cannot view XML input using style sheet. Please correct the > > > error and then > > > click the Refresh button, or try again later. > > > > > > > > > ------------------------------------------------------------------ > > > ---------- > > > -- > > > > > > Required white space was missing. Error processing resource > > > 'http://localhost/php%20test/info.php'. Line 1, Position 63 > > > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> > > > > > > > > > > > > > > > > > > Any help wouild be appreicated as I'm completely new to php. > > > > > > Cheers, > > > > > > Baz > > > > > > > > > > > > -- > > > PHP Windows Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php