function recipe_export_recipeml in Recipe 5
This function is called by recipe_export() to generate RecipeML for export.
Parameters
nid:
- an integer representing the node id (nid) of the node to export
Return value
- string containing the recipe in RecipeML
File
- ./
recipe.module, line 889 - recipe.module - share recipes for drupal 5.x
Code
function recipe_export_recipeml($nid) {
if ($nid == 0) {
drupal_goto('recipe');
}
$node = node_load(array(
'nid' => $nid,
'type' => 'recipe',
));
drupal_set_header('Content-type: text/xml');
$output = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<!DOCTYPE recipeml PUBLIC "-//FormatData//DTD RecipeML 0.5//EN" "http://www.formatdata.com/recipeml/recipeml.dtd">' . "\n" . '<recipeml version="0.5">' . "\n" . ' <recipe>' . "\n" . ' <head>' . "\n" . ' <title>' . $node->title . '</title>' . "\n" . ' </head>' . "\n" . ' <yield><qty>' . $node->yield . '</qty></yield>' . "\n" . ' <ingredients>';
foreach ($node->ingredients as $ingredient) {
$output .= "\n" . '<ing><amt><qty>' . $ingredient->quantity . '</qty><unit>' . $ingredient->abbreviation . '</unit></amt><item>' . $ingredient->name . '</item></ing>';
}
$output .= "\n" . ' </ingredients>' . "\n" . ' <directions>' . $node->instructions . '</directions>' . "\n" . ' </recipe>' . "\n" . '</recipeml>';
return $output;
}