function export_xml($xmldata)
{
    $output_xml[] = android_xml_start();
    $output_xml[] = android_xml_comments("Menu Item Categories");
    $output_xml[] = android_xml_stringarray_start("categories");
    $output_xml[] = join(PHP_EOL, array_map('android_xml_cdata', $xmldata['catdex']));
    $output_xml[] = android_xml_stringarray_end();
    foreach ($xmldata['category'] as $cat) {
        $output_xml[] = "";
        $output_xml[] = "";
        // comments
        $output_xml[] = android_xml_comments($cat['name']);
        // items
        $output_xml[] = android_xml_stringarray_start($cat['items_name']);
        $output_xml[] = join(PHP_EOL, array_map('android_xml_cdata', $cat['items']));
        $output_xml[] = android_xml_stringarray_end();
        // details
        $output_xml[] = android_xml_stringarray_start($cat['details_name']);
        $output_xml[] = join(PHP_EOL, array_map('android_xml_cdata', $cat['details']));
        $output_xml[] = android_xml_stringarray_end();
    }
    $output_xml[] = android_xml_end();
    return join(PHP_EOL, $output_xml);
}
function export_xml($xmldata, $title = CATXML_TITLE, $varname = CATXML_VARNAME)
{
    $output_xml[] = android_xml_start();
    // list categories
    $output_xml[] = android_xml_comments($title);
    $output_xml[] = android_xml_stringarray_start($varname);
    $output_xml[] = join(PHP_EOL, array_map('android_xml_cdata', $xmldata['catdex']));
    $output_xml[] = android_xml_stringarray_end();
    // for each category, list items and details
    foreach ($xmldata['category'] as $cat) {
        // provides two newlines for spacing (neatness counts)
        $output_xml[] = "";
        $output_xml[] = "";
        // comments
        $output_xml[] = android_xml_comments($cat['name']);
        // items
        $output_xml[] = android_xml_stringarray_start($cat['items_name']);
        $output_xml[] = join(PHP_EOL, array_map('android_xml_cdata', $cat['items']));
        $output_xml[] = android_xml_stringarray_end();
        // details
        $output_xml[] = android_xml_stringarray_start($cat['details_name']);
        $output_xml[] = join(PHP_EOL, array_map('android_xml_cdata', $cat['details']));
        $output_xml[] = android_xml_stringarray_end();
    }
    $output_xml[] = android_xml_end();
    return join(PHP_EOL, $output_xml);
}