当前页面: 开发资料首页 → J2EE 专题 → 读xml文件报错
读xml文件报错
摘要: 读xml文件报错
写了一个类读xml
有的时候读取没有问题,没有报任何的错误
但有的时候就报错
错误如下
[Fatal Error] :2:6: The processing instruction target matching "[xX][mM][lL]" is not allowed.
org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:264)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:98)
程序如下
DocumentBuilderFactory fa = DocumentBuilderFactory.newInstance();
DocumentBuilder db= fa.newDocumentBuilder();
Document doc = db.parse(is);
请问这个是哪里的错误?
谢谢!
路过,友情up...
自己顶一下
遇见过这个问题,
没有做什么实际的操作,
只是在开始的<?xml前面加了几个空格
重新保存一下
问题就没了
我的问题可能是xml反应迟钝造成的
当然我的语法是正确的
如果从别的地方拷贝过来一个xml文件会出这个错误
不知道你是不是这个问题