Parse a PHP file as an XML file?

Prototype

New Member
I have been working on a project that displays data in an XML file. (It's kind of like an API). I know how to parse XML with PHP, and how to make an XML file in PHP, but they don't work together. :)Basically, I have two files: \[code\]parse.php\[/code\] and \[code\]xml.php\[/code\].\[code\]xml.php\[/code\] grabs info from a MySQL database, and outputs it as XML.\[code\]parse.php\[/code\] loads and parses \[code\]xml.php\[/code\] and outputs it as HTML.If I run \[code\]parse.php\[/code\], it does not load \[code\]xml.php\[/code\]. However, if I copy the outputted XML (from \[code\]xml.php\[/code\]) and save it as a xml.xml file (and change the filename in \[code\]parse.php\[/code\] to 'xml.xml') it works. I'd really appreciate any help.Content of parse.php:\[code\]<?php $doc = "xml.php"; $doc = @simplexml_load_file($doc) or die("Server Error: Recipe not found!"); $title = $doc->title; echo $title?>\[/code\]Content of xml.php:\[code\]<?php header("Content-type: text/xml"); $dbc = mysql... //gets data from database echo "<!DOCTYPE..."; //xml stuff here echo "<title>" . $dataFromMySQL . "</title>";?>\[/code\]The database connection works, and the DOCTYPE in the XML is ok, so that's not the problem.Again, I only get the problem when I generate XML dynamically using PHP. If it's a .XML file, it works fine.Can anyone help me?Thanks.
 
Back
Top