function dumpxml($arbre_id) { print "<arbre>"; $sql = "select * from " . __racinebd__ . "arbre where arbre_id=" . $arbre_id; $link = query($sql); $tbl_result = fetch($link); dumpmeta($link, $tbl_result); $sql = "select * from " . __racinebd__ . "contenu where arbre_id=" . $arbre_id; $link = query($sql); while ($tbl_result = fetch($link)) { ?> <contenu><?php dumpmeta($link, $tbl_result, "arbre_id"); $sql = "select * from " . __racinebd__ . "content where contenu_id=" . $tbl_result["contenu_id"]; $link2 = query($sql); while ($tbl_result2 = fetch($link2)) { ?> <content><?php dumpmeta($link2, $tbl_result2, "contenu_id"); ?> </content> <?php } ?> </contenu> <?php } $sql = "select * from " . __racinebd__ . "arbre where pere=" . $arbre_id; $link = query($sql); while ($tbl_result = fetch($link)) { ?> <childs><?php echo dumpxml($tbl_result["arbre_id"]); ?> </childs> <?php } print "</arbre>"; }
<?php require "../require/function.php"; require "../require/back_include.php"; testsession(); //print dumparbre($_GET["arbre_id"]); header("Cache-control: private"); ob_start(); print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; dumpxml($_GET["arbre_id"]); print "</xml>"; $streamXML = ob_get_contents(); ob_end_clean(); Header('Content-Type: application/octet-stream'); if (headers_sent()) { echo 'Some data has already been output to browser, can\'t send CSV file'; } Header('Content-Type: application/xml'); Header('Content-Length: ' . strlen($streamXML)); Header('Content-disposition: attachment; filename=dump.xml'); echo $streamXML;