From the course: PHP: Exporting Data to Files
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Generating XML from a database result - PHP Tutorial
From the course: PHP: Exporting Data to Files
Generating XML from a database result
To generate XML from a database result, we're going to use the XML class, which is in the Foundationphp>Exporter name space. It's in this file here, Xml.php. If you haven't already copied the Foundationphp classes to your testing server, you can find a copy in the src folder, of the exercise files for this video. The XML class extends the base class that was described in chapter two. So let's just scroll down and take a look at the constructor method, and see which arguments it takes. The method begins on line 86, and it takes three arguments. The first one is the only one that is required. It needs to be a database result generated by MySQL improved or PDO. The second argument, file name, has a default value of null. This is because the primary purpose of this class is to generate an XML string that can be used to merge the database results with an XSLT stylesheet. However, the class can also save the XML to a local file on the web server, or download it to the user's computer. The…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.