我无法为在 DOM4J 中获取节点以进行教育任务编写正确的 Xpath 条件; 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> 


     

我只需要改变这一行 https://www.google.ru/search?q=ajnj&lr=&newwindow=1&sa=G&hl=ru&sxsrf=ALeKk01kgWRNvElYeXm0YUe7ZHdTAz6Mag:1610541612260&tbm=isch&source=iu&ictx=1&fir=xmiW7S4go2DcxM%252CoaO_EbjxGFa_FM%252C_&vet=1&usg=AI4_-kQAxhgZyDoyq2TTuqUf50TSroofWw&ved=2ahUKEwilgceF95juAhXE4IUKHVCcBT0Q9QF6BAgOEAE&biw=1777&bih=876#imgrc=xmiW7S4go2DcxM

     List<Node> nodes = document.selectNodes("/music/style/band[genge[text()='Hard Rock']]/name");
     nodes.stream().map(n -> n.getStringValue()).forEach(System.out::println);    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...