generate_xml returns stream, rather than directly printing.