`

org.dom4j.DocumentException: Error on line 1 of document : 缺少文件根组件。

阅读更多
在用dom4j解析xml时出现错误如下:
org.dom4j.DocumentException: Error on line 1 of document  : 缺少文件根组件。 Nested exception: 缺少文件根组件。
at org.dom4j.io.SAXReader.read(SAXReader.java:355)
at org.dom4j.io.SAXReader.read(SAXReader.java:219)
at cn.org.nciic.api.NciicServices.client.CarInfoCheck.parserXML(CarInfoCheck.java:274)
at cn.org.nciic.api.NciicServices.client.CarInfoCheck.main(CarInfoCheck.java:389)
Nested exception:
org.xml.sax.SAXParseException: 缺少文件根组件。
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3364)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:668)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at org.dom4j.io.SAXReader.read(SAXReader.java:219)
at cn.org.nciic.api.NciicServices.client.CarInfoCheck.parserXML(CarInfoCheck.java:274)
at cn.org.nciic.api.NciicServices.client.CarInfoCheck.main(CarInfoCheck.java:389)
Nested exception: org.xml.sax.SAXParseException: 缺少文件根组件。
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3364)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:668)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at org.dom4j.io.SAXReader.read(SAXReader.java:219)
at cn.org.nciic.api.NciicServices.client.CarInfoCheck.parserXML(CarInfoCheck.java:274)
at cn.org.nciic.api.NciicServices.client.CarInfoCheck.main(CarInfoCheck.java:389)
在网上搜索了各位兄弟姐妹们的帖子,解决不了问题。  后来用XMLSpy打开我的xml时,发现一个元素的为小写,因为其他的元素都是大写的,所以导致了这个错误....
汗....
花了半个小时的时间....
分享到:
评论
2 楼 羽风之扬 2012-09-29  
求把你的解析XML的代码贴出来
1 楼 mon0806 2012-08-29  
大哥,你的文章救了我啊,,,感恩!

相关推荐

    org.dom4j.jar

    java.lang.ClassNotFoundException: org.dom4j.DocumentException 缺少dom4j.jar包 加进去即可

    使用 dom4j 解析 XML

    使用 dom4j 解析 XML;很不错的中文文档

    itextpdf5.4.3+itextasian5.2.0

    解决 com.itextpdf.text.DocumentException: Font 'STSongStd-Light' with 'UniGB-UCS2-H' is not recognized. 亲测可用!

    tif 转合并 pdf itext java

    这是本人最近工作中的一个真实项目,将tif文件转换成pdf文件或者把多个tif文件合并成一个pdf文件。在这里跟大家分享下,希望能帮到哪位朋友。 内附详细代码及说明 和 itext包

    poi所有jar,dom4j-1.6.1.jar,xmlbeans-2.6.0.jar

    解决:HSSFWorkbook 解决:java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlOptions 解决:java.lang.NoClassDefFoundError: org/dom4j/DocumentException

    xml简单实现学生管理系统!看不懂来打我!!!

    目录一:项目分析二:实现步骤1.Dom4j工具类2.创建xml文件:3.Service层4.测试方法 一:项目分析 学生管理系统: 通过利用xml文件的存储功能来存储学生信息。再用dom4j解析器来对xml文件进行操作,也会用到一点xpath...

    在dom4j中使用XPath的简单实例

    import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Node; import org.dom4j.io.SAXReader; public class Demo4 { public static void main(String[] args) throws ...

    C#创建PDF文件一例

    // step 1: creation of a document-object Document document = new Document(); try { // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a ...

    JAVA读XML:sax,dom,jdom,dom4j的比较以及选择.doc

    JAVA读XML:sax,dom,jdom,dom4j的比较以及选择.doc

    java项目超市

    import org.dom4j.DocumentException; public class ServerThread extends Thread{ private Socket socket=null; public ServerThread(Socket socket){ this.socket=socket; } public void run(){ // 1....

    Tomcat解析XML和反射创建对象原理

    下面通过实例代码给大家介绍Tomcat解析XML和反射创建对象...import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; public class ServerReadXML1

    dom4j 使用简介 代码 程序

    // )(Z QXML,*B(Z_,+, XML (E ...MalformedURLException, DocumentException { SAXReader reader = new SAXReader(); Document document = reader.read(new File(fileName)); return document; }

    用户注册和登录是每个系统的必须存在的一部分,基于Dwr+Struts2+Spring+Hibernate写了一个用户登录注册系统

    22. //如果不用此包会抛出:java.lang.NoClassDefFoundError: org/dom4j/DocumentException 23. dom4j-1.6.1.jar 24. 25. //dwr必须 26. dwr.jar 27. 28. 29. //不用此包,在启动时招聘:java.lang....

    com.lowagie.text.jar

    java使用iText实现PDF文件添加水印功能的jar包

    itextsharp生成pdf插件

    BaseFont bfChinese = BaseFont.CreateFont(AppDomain.CurrentDomain.BaseDirectory + "SIMSUN.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, ...

    Java生成pdf的demo.rar

    Document document = new Document(PageSize.A4, 36.0F, 36.0F, 36.0F, 36.0F); public void getPDFdemo() throws DocumentException, IOException{ //这个导出用的是 iTextAsian.jar 和iText-2.1.3

    apache-cxf

    } catch (UnsupportedEncodingException | DocumentException e) { } catch (ClientException e) { } if(null == doc){ return null; } Element root = doc.getRootElement(); if(UtilValidator.isEmpty...

Global site tag (gtag.js) - Google Analytics