您的位置:首页 > 其它

Dom4j 根据指定的节点属性获取节点内容

2014-10-08 14:19 309 查看
<?xml version="1.0" encoding="UTF-8"?>
<config>
<sql name="ReportServiceImpl.SEARCH_TEMPLATE">
your sql here 1
</sql>
<sql name="ReportServiceImpl.SEARCH_TEMPLATE_UNION">
your sql here 2
</sql>
</config>

java代码片段如下:

public static String get(String attr){
Document doc = getXmlDocument();
Element root = doc.getRootElement();

Node node = root.selectSingleNode("sql[@name='"+attr+"']");	//[@name='ReportServiceImpl.findNormal']
//	System.out.println(node.getText());
return node.getText();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐