- 准备待解析xml文件nodelet_test.xml
<employee id="${id_var}"> <birth_date> <year>1970</year> <month>6</month> <day>15</day> </birth_date> </employee>
- 使用XPathParser解析xml内容
public void main(String [] args) throws Exception { try (InputStream inputStream = Resources.getResourceAsStream("nodelet_test.xml")) { XPathParser parser = new XPathParser(inputStream); Long year = parser.evalLong("/employee/birth_date/year") ; String id = parser.evalString("/employee/@id") ; log.info("year : {}, id : {}", year, id) ; // year: 1970, id: ${id_var} } }
XML解析器使用-mybatis学习笔记
最新推荐文章于 2022-10-10 16:37:50 发布