使用Dom4j和XPath解析spring 的配置文件
Map m = new HashMap<String, String>();m.put("s", "http://www.springframework.org/schema/beans");
XPath xpathSelector = DocumentHelper.createXPath("http://s:ref");
xpathSelector.setNamespaceURIs(m);
List<Node> list = xpathSelector.selectNodes(document);
注意對于使用schema進行驗證的spring configuration
要在XPath上加入域名空間。 xpathSelector.setNamespaceURIs(m);
posted on 2008-12-16 16:27 劉錚 閱讀(681) 評論(0) 編輯 收藏 所屬分類: Dom4j