$使用dom4j可解析 返回&#x等字样的 html转义字符
如果以GET或POST请求某个系统返回,带有 $#x 那很有可能是axis服务器返回的.
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><validateInvoiceResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><validateInvoiceReturn xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">{"returncode":"10006","returnmsg":"未获取到交易机构信息","fpdm":"null","fphm":"null","kprq":"null"}
</validateInvoiceReturn></validateInvoiceResponse></soapenv:Body></soapenv:Envelope>
实际内容:
{"returncode":"10006","returnmsg":"未获取到交易机构信息","fpdm":"null","fphm":"null","kprq":"null"}
参考 http://www.iteye.com/problems/73011
$$$$$ 使用dom4j可解析它
public static void main(String[] args) throws Exception {
String retXml = readStringFromFile("d://a.txt","GBK");//你刚得到的返回报文 Document document = DocumentHelper.parseText(retXml); OutputFormat format = OutputFormat.createPrettyPrint();
StringWriter sw = new StringWriter();
XMLWriter xw = new XMLWriter(sw, format);
xw.setEscapeText(false);
xw.write(document);
xw.flush(); String finalRetXml = sw.toString();
System.out.println("最终返回报文:\n"+finalRetXml);
}
最终得到:
文件 d://a.txt存在与否?: true
读到的文件内容如下:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><validateInvoiceResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><validateInvoiceReturn xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">{"returncode":"10006","returnmsg":"未获取到交易机构信息","fpdm":"null","fphm":"null","kprq":"null"}</validateInvoiceReturn></validateInvoiceResponse></soapenv:Body></soapenv:Envelope>
最终返回报文:
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<validateInvoiceResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<validateInvoiceReturn xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:string">{"returncode":"10006","returnmsg":"未获取到交易机构信息","fpdm":"null","fphm":"null","kprq":"null"}</validateInvoiceReturn>
</validateInvoiceResponse>
</soapenv:Body>
</soapenv:Envelope>
随机推荐
- 重放攻击(Replay Attacks)
重放攻击(Replay Attacks)1.什么是重放攻击顾名思义,重复的会话请求就是重放攻击.可能是因为用户重复发起请求,也可能是因为请求被攻击者获取,然后重新发给服务器. 2.重放攻击的危害请求被 ...
- byte与char的区别
byte 是字节数据类型 ,是有符号型的,占1 个字节:大小范围为-128—127 .char 是字符数据类型 ,是无符号型的,占2字节(Unicode码 ):大小范围 是0—65535 :char ...
- python数据分析之pandas库的DataFrame应用二
本节介绍Series和DataFrame中的数据的基本手段 重新索引 pandas对象的一个重要方法就是reindex,作用是创建一个适应新索引的新对象 ''' Created on 2016-8-1 ...
- PyCharm 远程连接linux中Python 运行pyspark
PySpark in PyCharm on a remote server 1.确保remote端Python.spark安装正确 2.remote端安装.设置 vi /etc/profile添加一行 ...
- 学习laravel之路由问题 404
今天配置路由的时候,只有原来的自带路由可用: Route::get('/', function(){ return View::make('hello');}); 再网上搜索了办法:来自:htt ...
- [JBoss] - JBAS015874: JBoss AS 7.1.1.Final "Brontes" started - Eclipse中不能正常启动的解决方法
在使用Eclipse + Jboss插件时,如果有时写配置文件写错,在重新启动发布JBoss时,会出现: 14:43:49,317 INFO [org.jboss.as] (Controller B ...
- Intel DPDK的一些参资料
dpdk.org What it is Intel® DPDK is a set of libraries and drivers for fast packet processing on x86 ...
- [zz] 混合高斯模型 Gaussian Mixture Model
聚类(1)——混合高斯模型 Gaussian Mixture Model http://blog.csdn.net/jwh_bupt/article/details/7663885 聚类系列: 聚类( ...
- ssl_error_rx_record_too_long
Linux下安装SSL 当使用https访问时出现: SSL 接收到一个超出最大准许长度的记录. (错误码: ssl_error_rx_record_too_long) 网上说修改虚拟机 vi /et ...
- (C#) 求两个数组的交集
基本上在面试的时候,会具体到两个int数组,或string数组.具体也就是讨论算法. 首先需要的是和面试的人确认题目的含义,并非直接答题. 然后,可以提出自己的想法,首先最快的是用linq { Lis ...