Added XML output mode, and handling of XML namespaces.