1
저는 Groovy/GPath의 신인이며 RestAssured와 함께 사용하고 있습니다. 쿼리 구문에 대한 도움이 필요합니다.GPath groovy 문에서 AND 절을 사용하여> 1 기준과 일치하는 모든 xml 노드를 얻습니다.
List<String> allSeatNos = response.extract().xmlPath().getList("**.findAll { it.name() == 'Seat'}[email protected]");
어떻게 어디 AllowChild = "true"로 모든 좌석 번호를 추출 할 수 있습니다 다음과 같이
<?xml version="1.0" encoding="UTF-8"?>
<SeatOptions FlightNumber="GST4747" AircraftType="737" NumberOfBlocks="2" Currency="GBP" Supplier="ABC">
<Seat Num="1A" Availabile="true" BandId="1" Block="1" Row="1" AllowChild="false" />
<Seat Num="1B" Availabile="true" BandId="1" Block="1" Row="1" AllowChild="false" />
<Seat Num="1C" Availabile="true" BandId="1" Block="1" Row="1" AllowChild="false"/>
<Seat Num="1D" Availabile="true" BandId="1" Block="2" Row="1" AllowChild="false" />
<Seat Num="1E" Availabile="true" BandId="1" Block="2" Row="1" AllowChild="true" />
<Seat Num="1F" Availabile="true" BandId="1" Block="2" Row="1" AllowChild="true" />
</SeatOptions>
내가 모든 좌석 번호를 추출 할 수 있습니다 :
은 다음 XML 조각을 감안할 때?나는 시도했다 :
List<String> childSeatNos = response.extract().xmlPath().getList("**.findAll { it.name() == 'Seat' & [email protected]() == 'true'}[email protected]");
그것은 예외 :
java.lang.IllegalArgumentException: Path '**'.findAll { it.name() == 'Seat' & [email protected]() == 'true'}.'@Num' is invalid.
올바른 구문은 무엇입니까?
감사합니다. 그러나 나는 여전히 IllegalArgumentException을받습니다. 따라서 문법 내에 일부 구문 오류가있을 수도 있습니다. – Steerpike
@Steerpike 식에 두 가지 더 많은 구문 오류가 발견되어 답변이 –
업데이트되었습니다. 고맙습니다 – Steerpike