Re: Can PHP Build XML Pages?

From: Date: Mon, 14 Jul 2003 17:08:37 +0000
Subject: Re: Can PHP Build XML Pages?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-155125@lists.php.net to get a copy of this message
There are 2 ways that i make xml files with php. 1. Use domxml to make the docs. (RTM this is somewhat complex.) 2. Just create it similar to html but use xml tags. The second way is really easy. 1. Make sure to send header content type as text/xml. header( "Content-Type: text/xml" ); 2. Just wrap you data with tags. Example: <?php header( "Content-Type: text/xml" ); $xmlpage = '<?xml version="1.0"?>'; $xmlpage .= '<page>'; foreach( $formdata => $index as $value ) { // $formdata is an associative array // meaning that $index is a name rather than // a array index number. $xmlpage .= '<'.$index.'>'.$value.'</'.$index.'>'; } $xmlpage .= '</page>'; echo $xmlpage; ?> This is a very simple example...but should get you up and running. -- BigDog On Mon, 2003-07-14 at 10:49, Jeffrey Fitzgerald wrote: > Looking for direction PHP and XML. I have a need to build a simple XML > doc from a PHP set of form vars. Any tips or examples are greatly appreciated. >

« previous php.general (#155125) next »