Re: Read a XML (not a file)

From: Date: Fri, 06 Feb 2009 16:39:28 +0000
Subject: Re: Read a XML (not a file)
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-287822@lists.php.net to get a copy of this message
Jônatas Zechim wrote: > Hi there, i want do read a XML like this: > > Server.php > <?php > > header ("content-type: text/xml"); > > echo "<?xml version=\"1.0\" encoding=\"iso-5718\" ?> > <images> <image> > <ID>1</ID> > <album>teste<album> > <path>/images/teste.jpg</path> > </image> > </images>"; > ?> > > How can do this? > > zechim > > test.php <?php # Capture original content-type $contentType = ini_get('default_mimetype'); ob_start(); include 'server.php'; $xml = ob_get_contents(); ob_end_clean(); # Reset content-type of previous type header("content-type: ".$contentType); echo $xml; ?> mind you that the header() call within the include is going to change the default headers(), so be sure to reset the content-type one you come out of the include file. -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare

« previous php.general (#287822) next »