Saving XML_Query2XML output to file?

aoknkrkx

New Member
I have a short script that utilizes the XML_Query2XML Pear plugin. It pulls data from a SQL database and outputs to the browser. The XML that appears in the browser is exactly what I want to be saved to a file, but any attempts to use ob_get_contents or any of the other methods I'm familiar with result in a blank output file. The code is as follows:\[code\]<?php set_include_path('/Library/WebServer/Documents/PEAR/'); include 'XML/Query2XML.php'; include 'MDB2.php'; try { // initialize Query2XML object $q2x = XML_Query2XML::factory(MDB2::factory('mysql://root:p[email protected]/site')); $sql = "SELECT * FROM Products"; $xml = $q2x->getFlatXML($sql); header('Content-Type: text/xml'); $xml->formatOutput = true; echo $xml->saveXML(); } catch (Exception $e) { echo $e->getMessage(); } ?>\[/code\]I'm wondering what the general procedure is for saving files with this plugin and output type (XML). Any help is greatly appreciated.
 
Top