问答详情
源自:3-1 使用 SAX 解析 XML 文件的开始和结束

为什么我的Prase方法一直报错啊,不管是Dom解析还是SAX解析

解析开始

org.xml.sax.SAXParseException; systemId: file:///E:/daima/SAXXmlTest/books.xml; lineNumber: 1; columnNumber: 3; 处理指令必须以目标名称开头。

at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)

at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)

at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)

at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)

at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)

at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPI(Unknown Source)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)

at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)

at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)

at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)

at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)

at javax.xml.parsers.SAXParser.parse(Unknown Source)

at testSAXXml.SaxXmlTest.main(SaxXmlTest.java:19)


提问者:gg的大牛之路 2016-08-12 17:26

个回答

  • gg的大牛之路
    2016-08-12 18:03:19

    已解决,XML文件中?和尖括号之间不能有空格。。。。。