Add as_xml() method