revise XML format
authorchriskl <chriskl>
Mon, 18 Aug 2003 07:21:44 +0000 (07:21 +0000)
committerchriskl <chriskl>
Mon, 18 Aug 2003 07:21:44 +0000 (07:21 +0000)
HISTORY
tblexport.php

diff --git a/HISTORY b/HISTORY
index ddca9b640da68d324db4eaf57dd336507b183717..85cbb938bb3d261ad8afba78e6bc611c8aaa35fa 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -27,6 +27,8 @@ Features:
 * When browsing data, numeric types are aligned right
 * Ability to create unique and partial indexes
 * View and edit table comments
+* Changed XML format significantly.  Now doesn't use field names as
+  tag names, outputs column type information, and is in correct XML format!
 
 Bug Fixes:
 * Lots of NULL value in table dump fixes (XML format changed slightly)
index 02b4fbc4b324c8fddefabee1677c797c4c1c4fe3..1ea9f811faa66c5b8ac138eb6b000b1c213280bf 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Does an export to the screen or as a download
         *
-        * $Id: tblexport.php,v 1.8 2003/08/03 03:14:13 chriskl Exp $
+        * $Id: tblexport.php,v 1.9 2003/08/18 07:21:45 chriskl Exp $
         */
 
        $extensions = array(
                echo "\\.\n";
        }
        elseif ($_REQUEST['format'] == 'xml') {
-               echo "<xml>\n";
+               echo "<?xml version=\"1.0\" ?>\n";
+               echo "<records>\n";
+               if (!$rs->EOF) {
+                       // Output header row
+                       $j = 0;
+                       echo "\t<header>\n";
+                       foreach ($rs->f as $k => $v) {
+                               $finfo = $rs->fetchField($j++);
+                               if ($k == $localData->id && !isset($_REQUEST['oids'])) continue;
+                               $k = htmlspecialchars($k);
+                               $type = htmlspecialchars($finfo->type);
+                               echo "\t\t<column name=\"{$k}\" type=\"{$type}\" />\n";
+                       }
+                       echo "\t</header>\n";
+               }
                while (!$rs->EOF) {
                        echo "\t<row>\n";
-                       while(list($k, $v) = each($rs->f)) {
+                       foreach ($rs->f as $k => $v) {
                                if ($k == $localData->id && !isset($_REQUEST['oids'])) continue;
 
                                $k = htmlspecialchars($k);
-                               $v = htmlspecialchars($v);
-                               echo "\t\t<{$k}", ($v == null ? ' null="true"' : ''), ">{$v}</{$k}>\n";
+                               if ($v != null) $v = htmlspecialchars($v);
+                               echo "\t\t<column name=\"{$k}\"", ($v == null ? ' null="yes"' : ''), ">{$v}</column>\n";
                        }
                        echo "\t</row>\n";
                        $rs->moveNext();
                }
-               echo "</xml>\n";
+               echo "</records>\n";
        }
        elseif ($_REQUEST['format'] == 'sql') {
                $data->fieldClean($_REQUEST['table']);