Re: Newbie: Setting content type

From: Date: Wed, 21 Aug 2002 15:29:40 +0000
Subject: Re: Newbie: Setting content type
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-15422@lists.php.net to get a copy of this message
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" <r.fleming@clara.co.uk> wrote in message news:PKEOKJGBCLBAKGDHPPFCKEDDCEAA.r.fleming@clara.co.uk... > 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:barry_langton@peoples.ac.uk] > > Sent: 21 August 2002 16:13 > > To: php-windows@lists.php.net > > 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 > > > > > > >

« previous php.windows (#15422) next »