dom4j解析xml报错:Nested exception: org.xml.sax.SAXParseException: White space is required between the processing instruction target and data.

采用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了。

时间: 2024-10-24 10:50:44

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

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/lesson01/src/newfile.xml : White spaces are required between publicId and systemId. Nested exception: White spaces are required between publicId and systemId

springmvc项目启动报错 nested exception is org.springframework.core.NestedIOException

学习springmvc的时候demo启动报错: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/zhanglingxiang/IdeaProjects/springmvc_hellow/out/artifacts/springmvc_hellow_war_exploded/WEB-INF/classes/co

Line 23 in XML document from class path resource [spring-mvc.xml] is invalid; nested exception is org.xml.sax.SAXParseException:

今天在把自己的项目转为maven架构的时候,居然碰到了一个很奇葩的问题具体如下: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 23 in XML document from class path resource [spring-mvc.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cos-all-l

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

报错文件:/SSM_Integration/WebContent/WEB-INF/applicationContext.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:mybatis="http://mybatis.org/schema/mybatis-spring" xmlns:xsi="http://www.w3.org/201/XMLSchema-inst

(待解答)Spring报错:Exception in thread &quot;main&quot; org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named &#39;car&#39; is defined

新建了一个Spring工程,有2个类:HelloWorld.Car.在Main.java文件里获取类时,发现只能获取到HelloWorld类,不能获取到Car类. HelloWorld.java: 1 package com.tt.spring.beans; 2 3 public class HelloWorld { 4 5 private String name; 6 7 public void setName(String name) { 8 System.out.println("hell

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

背景:在eclipse项目中,经常会遇到xml文件提示找不到.xsd文件的情况.很有必要弄清xsd文件的加载过程! 1 解决过程 dubbo-demo-provider导入eclipse后dubbox-demo-provider.xml报错详情: Multiple annotations found at this line: - cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be

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

问题: 1.新建项目后会提示一个这样的错 maven-compiler-plugin:3.1:compile(1 errors) maven-compiler-plugin:3.1:testCompile(1 errors) 2.关掉后看pom.xml 3.plugin标签也报错,无法解析 鼠标放红叉上提示 错误: CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compil

新建maven工程时pom.xml报错

新建maven工程时,pom.xml报错:第一行报如下错误:multiple annotations found at this line后添加org.eclipse.m2e相关的plugin配置后,错误消失,完整pom.xml如下: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schem

xml报错 Parse Fatal Error :在实体引用中,实体名称必须紧跟在&#39;&amp;&#39;后面

修改jndi配置文件中的密码后,重启tomcat报错如下  实际问题是xml中默认’&’是非法字符,用     &   替代 xml报错 Parse Fatal Error :在实体引用中,实体名称必须紧跟在'&'后面