fixed many bugs in xml output