Home  >  Article  >  Backend Development  >  Detailed explanation of how to handle the 'Content is not allowed in the preface' error when reading an XML file

Detailed explanation of how to handle the 'Content is not allowed in the preface' error when reading an XML file

黄舟
黄舟Original
2017-03-30 14:20:427717browse

When I use the jstl tag to read the XML file, I always get the error "Content is not allowed in the preface". After checking, the XML file format and content are correct. After searching on Baidu, I found out that it was a file encoding problem.

Use Notepad to open the xml file and convert it to UTF-8. There will be a BOM header, so java will report the above error when reading.

Solution: Open it with notepad++, select "Encode in UTF-8 BOM-free format" in the format, and then save it. You can also use EmEditor to save as a file, and select "UTF-8 No Signature" when saving.

The above is the detailed content of Detailed explanation of how to handle the 'Content is not allowed in the preface' error when reading an XML file. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn