报错:Content is not allowed in prolog.
上网查,说可能是BOM问题,说很多编辑器保存UTF-8时会在前面加个0xFE之类的,
但是很多XML解析器又不认识。。。。
是这个原因吗?我更改了其他编码,也曾经用编辑器把0xFE去掉,没用啊。。。
其他回答:
对于UTF-8编码的文件来说, BOM头是可有可无的. 如果用dom4J加载含有BOM
头的UTF-8格式的xml文件, 却会抛出"Content is not allowed in prolog
"异常.
原来无BOM头的UTF-8文件在经过UltraEdit编辑后, UltraEdit会擅自作主添加一个
BOM头(EditPlus无此问题, 记事本似乎有此问题), 即使去掉UltraEdit中与BOM相
关的所有设置选项也无济于事. 后来在UltraEdit论坛搜索答案, 有人提到11版以后
(含)的UltraEdit"另存为"对话框提供了另存为"UTF-8 - NO BOM"的一个选项.对理
想主义者来说, 这不能算是一个很完美的解决方法:(
进一步研究可以发现, IE/Windows记事本/XmlBuddy等等可正常显示含BOM头的
UTF-8格式文件.那么完美方案应该是让dom4j能正确读入含BOM头的UTF-8文件.
在dom4j的sourceforge论坛上已经有人就此提问, 但是答案中的链接已经失效. 再
|
|
/////////////////////////////
在 windows 上,檔案如果是存檔成 unicdoe 或是 utf-8 的時候,如果用 ultraedit
或是其他可以用二進元觀看檔案的軟體打開檔案,會看到檔案的開頭多了 FE FF 這 2 個位元組的東西,去年自己在玩 hibernate
時候,使用 xml 檔案做為 hibernate 初始化的設定檔,那時候曾出現一個怪問題,就是在讀取 xml 檔案的時候,xml parser
一直回報 Content is not allowed in prolog
的錯誤訊息,上網查了查資料後,才發現原來是因為檔案的前面有unicdoe 的 BOM 識別字元。
http://hiwzg.iteye.com/blog/82203
http://jkyeah.spaces.live.com/blog/cns!F1E94866655D7319!131.entry
说的简单点就是UE,会自动加上BOM的头,用EditPlus就不会了。
分享到:
相关推荐
设置隐试打开PPT报错 Hiding the application window is not allowed
keil常见错误 keil常见错误 keil常见错误 keil常见错误
Host 主机名 is not allowed to connect the mysql server 原因:没有授权远程访问mysql 解决方法: cmd 中运行mysql -u root -p(如果报mysql 不是内部或外部命令,找到安装mysql对应的bin文件夹运行mysql.exe,...
nginx: [emerg] “proxy_cache_path” directive is not allowed here in /etc/nginx/conf.d/default.conf:29 提示意思“proxy_cache_path指令不被允许”,在官网上查找了相关说明,也没有发现问题,最后看应用范围...
"Host 'localhost' is not allowed to connect to this MySQL server" 的原因及解决办法
keil 编译时出现错误和警告总结 中国电子DIY之家
algorithm2e.sty — package for algorithms 用于编辑算法伪代码等。
从3GPP协议和UE端行为分析5G gmm cause #27的网络问题
mongod高级查询语句,Javascript查询和$where查询,正则表达式匹配
java.sql.SQLException: null, message from server: “Host ‘223.72.41.7’ is not allowed to connect to this MySQL server” 客户端访问时报错: 解决方法: 1,登陆服务器 mysql> use mysql; //用mysql ...
directories that will not be allowed to be processed by Diskeeper. Event Logging ------------- Diskeeper records information about its activity in two ways. First, general information about ...
主要介绍了php采用curl访问域名返回405 method not allowed提示的解决方法,需要的朋友可以参考下
解决:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after statement closed.
NULL 博文链接:https://rayoo.iteye.com/blog/1973032
Android WebView 报 Not allowed to load local resource错误的解决办法 博客地址:http://blog.csdn.net/yuzhiqiang_1993/article/details/76228541
解决SQLSERVER无法安装的问题,提示文件挂起的错误,通过该东东能彻底解决。
opencv-2.4.9/modules/gpu/src/nvidia/core/NCVPixelOperations.hpp(51): error: a storage class is not allowed in an explicit specialization 这是由于NCVPixelOperations.hpp的问题,只要替换opencv-2.4.9/...
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation;...
NULL 博文链接:https://yizhilong28.iteye.com/blog/1137285
Origin 'null' is therefore not allowed access. 这就是跨域问题。解决方案有不少,比较好的是服务器端配置CORS,但要求服务器端做更改。如果在不需要更改服务器端的情况下解决呢?尤其是需要在