xml - 我无法编写正确的 Xpath 条件来获取 DOM4J 中的节点以执行教育任务;dasd2312 dsad213esada2 ddaasdas
问题描述
<?xml version="1.0"?>
<music>
<style type="rock">
<band id="1">
<name>Led Zeppelin</name>
<genre>Hard Rock</genre>
<cast>
<artist type="vocal">Robert Plant</artist>
<artist type="drums">John Bonham</artist>
<artist type="bass">John Paul Jones</artist>
<artist type="guitar">Jimmy Page</artist>
</cast>
</band>
<band id="2">
<name>Scorpions</name>
<genre>Heavy Metal</genre>
<cast>
<artist type="rhythm guitar">Rudolf Schenker</artist>
<artist type="lead guitar">Matthias Jabs</artist>
<artist type="bass">Pawel Maciwoda</artist>
</cast>
</band>
</style>
</music>
List<Node> nodes = document.selectNodes("/music/style/band[genge[text()='Hard Rock']]/name");
nodes.stream().map(n -> n.getStringValue()).forEach(System.out::println);
解决方案
推荐阅读
- javascript - 使用客户端javascript检查注册表项的存在
- java - KafkaIO with BootStrapServers
- reactjs - 使用 React Router 处理“找不到页面”
- typescript - 具有映射和条件类型的递归类型定义
- c - asm volatile("" ::: "memory") 的便携式等价物?
- css - MediaWiki:如果菜单是西里尔文,如何在每个菜单的侧边栏中添加图像(图标)?
- c# - SqlBulkCopy.WriteToServer 工作需要哪些 GRANTS?
- swift - Xcode 13,Swift5.5,“错误:'FilePath' 类型的值没有成员'components'”
- azure-data-factory - 如何替换包含字符串的字符串中的所有\
- android - 如何使用 Android ShareSheet 实现此行为?