0
僅當描述爲T1並且使用xPath列表中的每個作業描述值(Mecánica,Guarnecidos,...)時,我需要獲取值28.42。在Java中使用xPath獲取節點
<priceByHourList>
<priceByHour locked="false">
<value>
<job>
<jobId>4</jobId>
<description>
<id>4</id>
<value>Mecánica</value>
</description>
</job>
<technician>
<technicianId>1</technicianId>
<description>T1</description>
</technician>
<value>28.42</value>
</value>
</priceByHour>
<priceByHour locked="false">
<value>
<job>
<jobId>4</jobId>
<description>
<id>4</id>
<value>Mecánica</value>
</description>
</job>
<technician>
<technicianId>2</technicianId>
<description>T2</description>
</technician>
<value>28.42</value>
</value>
</priceByHour>
<priceByHour locked="false">
<value>
<job>
<jobId>4</jobId>
<description>
<id>4</id>
<value>Mecánica</value>
</description>
</job>
<technician>
<technicianId>3</technicianId>
<description>T3</description>
</technician>
<value>28.42</value>
</value>
</priceByHour>
<priceByHour locked="false">
<value>
<job>
<jobId>1</jobId>
<description>
<id>1</id>
<value>Electricidad</value>
</description>
</job>
<technician>
<technicianId>2</technicianId>
<description>T2</description>
</technician>
<value>28.42</value>
</value>
</priceByHour>
<priceByHour locked="false">
<value>
<job>
<jobId>1</jobId>
<description>
<id>1</id>
<value>Electricidad</value>
</description>
</job>
<technician>
<technicianId>3</technicianId>
<description>T3</description>
</technician>
<value>28.42</value>
</value>
</priceByHour>
<priceByHour locked="false">
<value>
<job>
<jobId>5</jobId>
<description>
<id>5</id>
<value>Guarnecidos</value>
</description>
</job>
<technician>
<technicianId>1</technicianId>
<description>T1</description>
</technician>
<value>28.42</value>
</value>
</priceByHour>
而我試圖讓列表中,但該節點是一樣的。
for (int i = 0; i < nodes.getLength(); i++) {
Element pieza = (Element) nodes.item(i);
System.out.println(pieza.getNodeName());}
這是JSoup? –
是否嘗試過'// value [.// description =「T1」]/value/text()'? – Andersson