Jump to content

XML and PHP in same file


Kevin M

Recommended Posts

For the blog system I'm currently working on, I'm going to use a MySQL databse to generate the XML file and it's contents. My only question is, how would it be possible to have an XML file contained in a PHP file, or vise versa? Or is this already possible? I'm not parsing the XML with PHP, I'm going to use XSLT to make the file readable. Thanks,Kevin

Link to comment
Share on other sites

Why wouldn't you transform the generated XML file with PHP? It's dependable on PHP (and MySQL for that matter) anyway.PHP can have anything as it's output, including XML, but you'll have to include this before any actual output:

header('Content-type: application/xml');

You can use the generated tree as input for XSLT transformation by loading the XML text with the loadXML() function, or generate the new DOM tree itself with the PHP DOM functions. The above code is not required if you do so.

Link to comment
Share on other sites

Oh, I figured it was use one or the other, not both. I knew it was possible to pars XML in PHP, but I don't have much experience with it. I will have to look into that more. Thanks again.

Link to comment
Share on other sites

Just a pointer...Look at the DOM class and XSL class. If you want to be PHP4 compatable, look at the XSLT functions. Just wanted to verify you're checking the right stuff :) .

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...