I have really annoying problem. I was looking for resolve on google and stackoverflow, trying to fix it but I tried a lot of solutions and it is still not working.
I want to read XML Data from XML File using DocumentBuilder.
This is my code:
public void LoadFromFile(){
try{
//File fXmlFile = new File("fishlist.xml");
DocumentBuilderFactory dbFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse("file:///C:/fishlist.xml"); // <--- there is exception run
doc.getDocumentElement().normalize();
}catch(Exception ex){
ex.printStackTrace();
}
}
and when I'm trying to run this method, it shows me Exception:
W/System.err: java.io.FileNotFoundException: /C:/fishlist.xml: open failed:
ENOENT (No such file or directory)
W/System.err: at libcore.io.IoBridge.open(IoBridge.java:456)
W/System.err: at java.io.FileInputStream.<init>(FileInputStream.java:76)
W/System.err: at
libcore.net.url.FileURLConnection.connect(FileURLConnection.java:123)
W/System.err: at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.jav
a:117)
W/System.err: at
javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:155)
W/System.err: Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
W/System.err: at libcore.io.Posix.open(Native Method)
W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
W/System.err: at libcore.io.IoBridge.open(IoBridge.java:442)
And yes. I have this file in that direction. Please help.