2008-01-21
dom4j操作xml
关键字: dom4j xml<Elements xmlns="http://www.163.com" xmlns:dc="http://www.163.com">
<test>
<title> 标题 </title>
</test>
</Elements>SAXReader saxReader = new SAXReader();
Document document = saxReader.read(new File(filename));
HashMap xmlMap = new HashMap();
xmlMap.put("plugins","http://www.163.com"); //假设的命名空间
XPath x = document.createXPath("//plugins:test/plugins:title"); //读取二级节点,研究了半天
x.setNamespaceURIs(xmlMap);
Element valueElement = (Element)x.selectSingleNode(document);
System.out.println(valueElement.getText()); //输出该节点内容
发表评论
- 浏览: 13738 次
- 性别:

- 来自: 大连

- 详细资料
搜索本博客
最新评论
-
JSP页面EL表达式无效的问 ...
el需要 servlet 2.4 吧
-- by srdrm -
分页显示数据代码
用iBATIS做分页的确很方便。
-- by cyberblue -
DB2——JDBC个人记录 (2)
我用COM.ibm.db2.jdbc.net.DB2Driver 这种方式连接, ...
-- by 燕子~~ -
JSP页面EL表达式无效的问 ...
EL要在jstl2.0以上才能支持
-- by yangpeihai -
Spring常用Interface&Clas ...
对对,混淆了,呵呵
-- by gimgen1026






评论排行榜