debugged selection to_xml