采用dom4j方式解析string类型的xml

xml:        String string="<?xmlversion=\"1.0\" encoding=\"UTF-8\"?><ROOT><HEAD><INFO><BUSINESSNO>T065205072015000097</BUSINESSNO><BUSINESSTYPE>T</BUSINESSTYPE></INFO></HEAD></ROOT>";
时,报错:Nested exception: org.xml.sax.SAXParseException: White space is required between the processing instruction target and data.

后来发现原来是xml格式有误。xmlversion应改为xml version.即xml和version之间应该有一个空格。

改为

string="<?xml version=\"1.0\" encoding=\"UTF-8\"?><ROOT><HEAD><INFO><BUSINESSNO>T065205072015000097</BUSINESSNO><BUSINESSTYPE>T</BUSINESSTYPE></INFO></HEAD></ROOT>";就OK了。

dom4j解析xml报错:Nested exception: org.xml.sax.SAXParseException: White space is required between the processing instruction target and data.的更多相关文章

  1. xml操作-Nested exception: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId. 异常处理

    异常如下: org.dom4j.DocumentException: Error on line 2 of document file:///D:/workspaces/struts2/lesson0 ...

  2. springboot 报错nested exception is java.lang.IllegalStateException: Failed to check the status of the service xxxService No provider available for the service

    spring: dubbo:#关闭所有服务的启动时检查:(没有提供者时报错) consumer: check: false timeout: 3000

  3. java运行报错:nested exception is java.lang.NoSuchFieldError: INSTANCE,但使用@Test测试是好的

    解决方法: 原因是,在tomcat里,同名不同版本的jar包,默认加载版本低的.我项目里有两个httpclient jar包.一个4.2.5  另一个是4.5.所以加载了4.2.5的,而我要用的是4. ...

  4. org.dom4j.DocumentException: unknown protocol: d Nested exception: unknown

    最近用dom4j写了一个修改XML文件的小例子,抛出了如下异常: org.dom4j.DocumentException: unknown protocol: d Nested exception: ...

  5. SSM——[/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; cvc-elt.1: 找不到元素 'beans' 的声明。

    报错文件:/SSM_Integration/WebContent/WEB-INF/applicationContext.xml <beans xmlns="http://www.spr ...

  6. (转)解决dubbox-demo-provider.xml报错的问题:提示Failed to read schema document

    背景:在eclipse项目中,经常会遇到xml文件提示找不到.xsd文件的情况.很有必要弄清xsd文件的加载过程! 1 解决过程 dubbo-demo-provider导入eclipse后dubbox ...

  7. eclipse新建maven项目出错 pom.xml报错

    问题: 1.新建项目后会提示一个这样的错 maven-compiler-plugin:3.1:compile(1 errors) maven-compiler-plugin:3.1:testCompi ...

  8. web.xml文件报错:The processing instruction target matching "[xX][mM][lL]" is not allowed.

    昨晚把我的项目上传到了gitlab,然后今天在公司从gitlab下载下来, 发现web.xml报错.

  9. android 程序中res/values-v14/styles.xml报错的解决办法

    从旧的ADT迁移的新的ADT时, android 程序中res/values-v14/styles.xml报错: error: Error retrieving parent for item: No ...

随机推荐

  1. BZOJ 3529 数表(莫比乌斯+树状数组)

    题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=3529 题意:有一张n×m的数表,其第i行第j列的数值为能同时整除i和j的所有自然数 ...

  2. JavaScript:正则表达式 分组

    在现在的我看来,带小挂号的就是分组,嗯. 代码: var reg=/(abc)/; var str="abcdabcdeabcdef"; console.dir(reg.exec( ...

  3. POJ 3687 Labeling Balls(拓扑排序)题解

    Description Windy has N balls of distinct weights from 1 unit to N units. Now he tries to label them ...

  4. 安卓开发 Activity入门

    生命周期 Activity包含5种状态,涉及7种方法 1. 启动状态 2. 运行状态 *** 即使内存不足,Android先销毁栈底的Activity,来确保当前Activity正常运行 3. 暂停状 ...

  5. 查找SQL 存储过程、触发器、视图!

    ALTER proc [dbo].[SP_SQL](@ObjectName sysname)  as  set nocount on ;  declare @Print nvarchar(max)-- ...

  6. Leetcode ——Lowest Common Ancestor of a Binary Tree

    Question Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. ...

  7. java进制转换代码

    定义十进制的数直接写,定义8进制的数以0开头,定义二进制的数以0b开头,定义十六进制的数以0x开头需要将十进制的数以二进制的数表示出来可以参照下例: int a = 10; System.out.pr ...

  8. Ubuntu 14.04 python3.6 安装

    参考 how-do-i-install-python-3-6-using-apt-get Ubuntu 14.04 python3.6 安装 sudo add-apt-repository ppa:j ...

  9. UVa 1663 净化器

    https://vjudge.net/problem/UVA-1663 题意: 给m个长度为n的模板串,每个模板串包含字符0,1和最多一个星号"*",其中星号可以匹配0或1.例如, ...

  10. get-post区别

    原文链接:http://www.techweb.com.cn/network/system/2016-10-11/2407736.shtml GET和POST是HTTP请求的两种基本方法,要说它们的区 ...