这个问题已经在这里有了答案:
Prolog SAXParserException中不允许包含内容 5个答案
我正在用Java编写一个程序,该程序采用自定义XML文件并对其进行解析。 我正在使用XML文件进行存储。 我在Eclipse中收到以下错误。
[Fatal Error] :1:1: Content is not allowed in prolog.
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at .apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:239)
at .apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283 )
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:208)
at me.ericso.psusoc.RequirementSatisfier.parseXML(RequirementSatisfier.java:61)
at me.ericso.psusoc.RequirementSatisfier.getCourses(RequirementSatisfier.java:35)
at me.ericso.psusoc.programs.RequirementSatisfierProgram.main(RequirementSatisfierProgram.java:23 )
XML文件的开头包括:
Information Science and Technology
B.S.
Information Systems: Design and Development Option
GWS
GQ
该程序能够读取XML文件,但是当我调用DocumentBuilder.parse(XMLFile)来获取已解析的org.w3c.dom.Document时,出现上述错误。
在我看来,我的XML文件的序言中没有无效的内容。 我不知道怎么了。 请帮忙。 谢谢。