diff --git a/format.cc b/format.cc
index 534a592a..7b3012bb 100644
--- a/format.cc
+++ b/format.cc
@@ -654,8 +654,11 @@ void format_xml_entries::format_last_entry()
xml_write_value(output_stream, value_t((*i)->amount), 10);
output_stream << " \n";
- if ((*i)->cost)
- output_stream << " " << *(*i)->cost << "\n";
+ if ((*i)->cost) {
+ output_stream << " \n";
+ xml_write_value(output_stream, value_t(*(*i)->cost), 10);
+ output_stream << " \n";
+ }
if (! (*i)->note.empty())
output_stream << " " << xml_string((*i)->note)