假设我有
<Sports>
<Soccer>
<Players>
<Player_1> Messi Leonel </Player_1>
</Players>
</Soccer>
</Sports>
如何使用Dom4J在一行无迭代中获取Player_1节点文本?
返回值应为:梅西莱昂内尔
感谢
答案 0 :(得分:3)
得到了看起来像这样的人
File file = new File("/path/to/file.xml");
SAXReader reader = new SAXReader();
Document document = reader.read(file);
String name = document.selectSingleNode("//Sports/Soccer/Players/Player_1").getText();