SAXBuilder从String创建Document对象
来源:互联网 发布:淘宝正义哥假货 编辑:程序博客网 时间:2024/04/30 05:10
参考:
http://laksmono.com/2010/02/18/how-to-convert-string-to-xml-using-jdom/
http://sudheersunny.blogspot.com/2012/05/how-to-parse-string-xml-using-jdom.html
http://www.tutorialspoint.com/java/io/stringreader_close.htm
要解析的XML文件
<?xml version="1.0" encoding="UTF-8"?></p><transDocument><commResponse><meta><code>0</code><description>Success</description></meta></commResponse></transDocument>
try {SAXBuilder xmlBuilder = new SAXBuilder();Reader reader = new StringReader(request.getParameter("hxml"));Document xmlDoc = this.xmlBuilder.build(reader);System.out.println("Root: " + xmlDoc.getRootElement().getName());} catch (JDOMException je) {je.printStackTrace();} finally {try {reader.close();} catch (IOException e) {}}
注意:
这里的reader最好在使用完了以后,将它close掉,以是否资源。
0 0
- SAXBuilder从String创建Document对象
- SAXBuilder,Document,Element等作用
- SAXBuilder、Document、Element的用法
- SAXBuilder、Document、Element的用法
- 如何从String得到xml中的对象如Document
- 从JVM的角度分析String对象的创建
- 从String对象的创建看ava堆栈
- String对象创建个数
- string创建对象
- String对象的创建
- String对象的创建
- String,创建对象问题
- String 创建对象问题
- String创建对象问题
- String,创建对象问题
- String对象创建个数
- String创建对象问题
- String对象创建
- Ibatis基础知识:#与$的区别
- Huffman 编码 数据结构
- JNI和NDK学习(1)--搭建开发环境
- java servlet过滤器应用场景
- HTML:各种距离说明scrollLeft,scrollWidth,clientWidth,offsetWidth
- SAXBuilder从String创建Document对象
- 目标板挂载NFS时“rpcbind: server localhost not responding, timed out”解决
- Base64算法实现
- CHeckBox后台版的连级选择(后期添加功能注释,现在直接上代码)
- Visual C# 3.0 新特性概览
- C++课程资源下载问题
- leetcode第一刷_Minimum Depth of Binary Tree
- myself
- Java 四则运算表达式求解