So here is my code... Which I used in my Project.
$app->post(
'/chk_db',
function () use ($app){
require_once 'lib/mysql.php';
$dx = connect_db('MyPhotos');
//XML RESPONSE
$app->response->setStatus(0);
$res = $app->response();
$res['Content-Type'] = 'application/xml';
$view = $app->view();
$view->setTemplatesDirectory('./');
$oArray = array("Status"=> $dx.status, "code" => $dx.code);
return $app->render('chkdb.xml', $oArray);
}
);
so i have this Array as an input to the xml template (by the way... this is json_encoded... I just use it to represent the array... thanks...)
[{"ObjID":"1","ParenetID":"10001","Path":"http:\/\/localhost\/img\/1.jpg","Title":"1st Image","ChildCount":"0","Owner":"jhim","Comment":"hehe","inode":"0"},
{"ObjID":"2","ParenetID":"10002","Path":"http:\/\/localhost\/img\/2.jpg","Title":"2nd Image","ChildCount":"0","Owner":"nemy","Comment":"test lang","inode":"0"},
{"ObjID":"3","ParenetID":"10003","Path":"http:\/\/localhost\/img\/3.jpg","Title":"3rd Image","ChildCount":"0","Owner":"jayjay","Comment":"para amy output","inode":"0"},
{"ObjID":"4","ParenetID":"10004","Path":"http:\/\/localhost\/img\/4.jpg","Title":"4th Image","ChildCount":"0","Owner":"jhim","Comment":"yeah boy","inode":"0"}]
How can I handle them on the template? chk_db.xml
{% for x in ????%}
<MyPhotos>
<ObjID>{{x.ObjID}}</ObjID>
...
<inode>{{x.inode}}</inode>
</MyPhotos>
{% else %}
<data>No data Found</data>
{% endfor %}
Thanks...