ciao!
ho un problema con il parsing di un file XML.
sostanzialmente non ottengo errori, però non fa il parsing.
ho controllato ed il file esiste.
questo il codice che richiamo in AsyncTask:
codice:
import java.io.File;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import android.content.Context;
public class ReadXml {
public void read(Context context, String file) throws SAXException,
IOException, ParserConfigurationException {
if (new File(file).exists()) {
System.out.println(file);
DocumentBuilderFactory builderFactory = DocumentBuilderFactory
.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder();
System.out.println("OK");
Document document = builder.parse(file);
document.getDocumentElement().normalize();
NodeList nodeList = document.getElementsByTagName("cliente");
System.out.println("OK");
}
}
}
questo l'output del logcat:
codice:
11-25 16:17:10.725: I/System.out(5406): /mnt/sdcard/clienti.xml
11-25 16:17:10.725: I/System.out(5406): OK
11-25 16:17:10.901: I/Choreographer(5406): Skipped 34 frames! The application may be doing too much work on its main thread.
11-25 16:17:11.115: I/Choreographer(5406): Skipped 53 frames! The application may be doing too much work on its main thread.
come vedete il file esiste, e ne stamoa anche il path.
però esce solo il primo OK, quello prima del parse.
avete qualche idea?