public void realxml(String fileName){
SAXReader saxreader= new SAXReader();
Document document=null;
try{
URL xmlpath = this.getClass().getClassLoader().getResource(fileName);
document = saxreader.read(xmlpath);
Map<String,String> nsMap = new HashMap<String,String>();
XPath xsub = document.createXPath("//ns:beans/ns:bean");//创建beans/bean的查询路径
xsub.setNamespaceURIs(nsMap);//设置命名空间
List<Elements> beans= xsub.selectNodes(document);//获取的
//文档所有的bean节点
for(Elements element:beans){
String id= element.attributeValue("id");
String clazz=element.attributeValue("class");
BeanDfinition beanDefine = new BeanBefinition(id,clazz);
beanDefine.add(beanDefine);
}
}
catch(Exception e){
e.printStackTrace();
}
}
//记得要建一个javabean(beanDefine)类来接受 id 和class (bean)