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

来源:3-1 使用 SAX 解析 XML 文件的开始和结束

gg的大牛之路

2016-08-12 17:26

解析开始

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)


写回答 关注

1回答

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

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

Java眼中的XML---文件读取

通过Java认识并且创造XML文件,如何应用 Java“解析 XML

83199 学习 · 431 问题

查看课程

相似问题

SAX解析xml

回答 2

SAX解析

回答 1

SAX解析

回答 3

SAX解析xml

回答 1