December 8th, 2012, 09:59 PM
Generating xml from database
I want to generate an xml for someone who is making an iphone ap. He wants xml. As I have never done this before, I wonder if this is o right or not? It works fine but I need to confirm. Outputs this
<?php include "includes.php";
$sql = "SELECT * FROM systematic_attraction_sub_categories WHERE status=:status ";
$args_sub = array('status'=>'active');
$data = DB::Load()->Execute($sql, $args_sub)->returnArray();
foreach($data as $val=>$row)
$My_videoss = new My_videos($row['title'], $row['description'], $row['price'], $row['thumbnail'], $row['youtube_link']);
function __construct($title, $description, $price, $thumbnail_url, $youtube_embed)
$this->title = $title;
$this->description = $description;
$this->price = $price;
$this->thumbnail_url = $thumbnail_url;
$this->youtube_embed = $youtube_embed;
$xmlDoc = new DOMDocument();
$root = $xmlDoc->appendChild(
foreach($My_videoss as $tut)
$tutTag = $root->appendChild(
$xmlDoc->formatOutput = true;
echo $file = $xmlDoc->saveXML();
December 10th, 2012, 08:17 AM
It outputs valid xml, so you're done?
It depends what your developer wants, does it contain all the information he wants?
Does he want it namespacing?
Does he want to validate the xml against a schema (xsd file)?
December 10th, 2012, 07:49 PM
The test version of the ap is working fine on iphone. I was just checking the way I am making the xml. Sometimes make things that work but they are not the best practice.
Originally Posted by Northie