2012-03-21 43 views
2

要解决这个问题吗?任何帮助?android:MalformedURLException:找不到协议

ERROR : java.net.MalformedURLException: Protocol not found: /mnt/sdcard/EREADER/NewForestPonies/OEBPS/content.opf 

代码:

 //Getting the xhtml file names 
       DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 
       DocumentBuilder db = dbf.newDocumentBuilder(); 
       String 
       Document doc = db.parse(new InputSource(Environment.getExternalStorageDirectory()+"/EREADER/"+book_name+"/OEBPS/content.opf")); //ERROR HERE 
       doc.getDocumentElement().normalize(); 

      .......... 
      ...... 

编辑: FOR SAX解析器:?

DataSaxHandler myXMLHandler = new DataSaxHandler(); 
      xr.setContentHandler(myXMLHandler); 
      xr.parse(new InputSource(Paths.getBookStorePath()+bookname+"/OEBPS/content.opf")); 

回答

2

试试这个,让我知道发生什么事..

File fXmlFile = new File(Paths.getBookStorePath()+book_name+"/OEBPS/content.opf"); 
    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); 
    DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); 
    Document doc = dBuilder.parse(fXmlFile); 
    doc.getDocumentElement().normalize(); 
+0

它为我工作..感谢了很多......但我有同样的问题FOR SAX解析器PLS请参阅编辑 – vnshetty 2012-03-21 10:26:30

+0

我使用,但它显示XMLReader类型中的方法解析(InputSource)不适用于参数(文件) – vnshetty 2012-03-21 10:31:34

+0

您可以发布完整的SAX解析器代码吗? – user370305 2012-03-21 10:36:10

相关问题