org.xml.sax.SAXParseException: Content is not allowed in prolog

前端 未结 30 2391
别那么骄傲
别那么骄傲 2020-11-22 02:54

I have a Java based web service client connected to Java web service (implemented on the Axis1 framework).

I am getting following exception in my log file:

30条回答
  •  天命终不由人
    2020-11-22 03:48

    I had the same problem with some XML files, I solved reading the file with ANSI encoding (Windows-1252) and writing a file with UTF-8 encoding with a small script in Python. I tried use Notepad++ but I didn't have success:

    import os
    import sys
    
    path = os.path.dirname(__file__)
    
    file_name = 'my_input_file.xml'
    
    if __name__ == "__main__":
        with open(os.path.join(path, './' + file_name), 'r', encoding='cp1252') as f1:
            lines = f1.read()
            f2 = open(os.path.join(path, './' + 'my_output_file.xml'), 'w', encoding='utf-8')
            f2.write(lines)
            f2.close()
    

提交回复
热议问题