后续问题到Big XML File:RE:大XML文件
首先非常感谢您的回答。 ......我做错了什么? 这是我的类,它使用SAX:
public class SAXParserXML extends DefaultHandler {
public static void ParcourXML() {
DefaultHandler handler = new SAXParserXML();
SAXParserFactory factory = SAXParserFactory.newInstance();
try {
String URI = "dblp.xml";
SAXParser saxParser = factory.newSAXParser();
saxParser.parse(URI,handler);
} catch (Throwable t) {
t.printStackTrace();
}
}
public void startElement (String namespaceURI,String simpleName,String qualifiedName,Attributes attrs) throws SAXException {
}
public void endElement (String namespaceURI,String simpleName,String qualifiedName) throws SAXException {
}
}
你可以看到,我什么都不做我的XML文件,但它给出了这样的错误:
java.lang.OutOfMemoryError: Java heap space
at com.sun.org.apache.xerces.internal.util.XMLStringBuffer.append(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.refresh(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.invokeListeners(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.peekChar(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.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 javax.xml.parsers.SAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at SAXParserXML.ParcourXML(SAXParserXML.java:30)
at Main.main(Main.java:28)
我也试过斯塔克斯......同样的错误......什么我可不可以做? 我也增加了Java堆大小可达1260M
java -Xmx1260M SAXParserXML
的XML文件有以下形式:
<dblp>
<incollection>
<author>... </author>
....
<author>... </author>
#other tags-i'm interested only by <author>#
...
</incollection>
<incollection>
# the same thing#
</incollection>
....
</dblp>
您可以找到原始文件:http://dblp.uni-trier.de/xml/
感谢
如果您告诉我们更多关于您正在解析的XML类型,这将有所帮助。 – 2009-02-03 21:03:00