Export menu to html? The project I'm working on has a specific requirement where I need to export the main menu as an HTML file. I figured the simplest way to do it would be using views but I found that views doesn't interact with the menu system.

I looked up the menu_import module to see how it exports menus to JSON files to see if I could rewrite the output to be HTML but haven't really gotten too far with that.

Any ideas how I can approach this?
Use the next code:

$tree = menu_tree_all_data('main-menu');
$menu_html = render(menu_tree_output($tree));
file_put_contents('myfile.txt', $menu_html);


Source: Programmatically load a menu.

EDIT
If you want to make it downloadable you can add next code to your page or submit callback:

// Get menu tree.
$tree = menu_tree_all_data('main-menu');
$menu_html = render(menu_tree_output($tree));

// Download menu txt file.
$filename = "menu.txt";
drupal_add_http_header('Content-Type', 'text/plain; charset=utf-8');
drupal_add_http_header('Content-Disposition', 'attachment; filename="' . $filename . '"');
drupal_send_headers();
echo $menu_html;
drupal_exit();