我想解析字符串中的XML。當字符串長度很小時,這工作正常。但是對於長字符串,它不解析任何東西。它在調用parse()時被暫停。我使用下面的代碼進行解析。請告訴我我的代碼有什麼問題?從Android中的字符串解析xml的問題
//my xml code is string 'xmlString'
DocumentBuilderFactory objDocFactory=DocumentBuilderFactory.newInstance();
DocumentBuilder objDocBuilder=objDocFactory.newDocumentBuilder();
InputSource objInput=new InputSource();
objInput.setCharacterStream(new StringReader(xmlString));
Document objDoc=objDocBuilder.parse(objInput);
//appication is suspended at the above line
objDoc.getDocumentElement().normalize();
謝謝...
如果您正在解析大型XML文檔,那麼您可能需要使用SAX解析器。 – Keith 2010-12-03 06:28:50