removed minidom dependency; improved handling of different encodings