空手道:匹配 xml 中的重复元素

Karate: Match repeating element in xml

我正在尝试将 xml 中的重复元素与空手道模式相匹配。

XML 留言

* def xmlResponse =
"""
<Envelope>
   <Header/>
   <Body>
      <Response>
         <Customer>
            <keys>
               <primaryKey>1111111</primaryKey>
            </keys>
            <simplePay>false</simplePay>
         </Customer>
         <serviceGroupList>
            <serviceGroup>
               <name>XXXX</name>
               <count>1</count>
               <parentName>DDDDD</parentName>
               <pendingCount>0</pendingCount>
               <pendingHWSum>0.00</pendingHWSum>
            </serviceGroup>
            <serviceGroup>
               <name>ZZZZZ</name>
               <count>0</count>
               <parentName/>
               <pendingCount>3</pendingCount>
               <pendingHWSum>399.00</pendingHWSum>
            </serviceGroup>
         </serviceGroupList>
      </Response>
   </Body>
</Envelope>
"""

我想将每个空手道模式与以下空手道模式相匹配

 Given def serviceGroupItem =
  """
    <serviceGroup>
               <name>##string</name>
               <count>##string</count>
               <parentName>##string</parentName>
               <pendingCount>##string</pendingCount>
               <pendingHWSum>##string</pendingHWSum>
            </serviceGroup>
  """

这是我试过的方法

  * xml serviceGroupListItems = get xmlResponse //serviceGroupList
  * match each serviceGroupListItems == serviceGroupItem

但是没用。知道我怎样才能让它工作

您必须匹配每个服务组。

* xml serviceGroupListItems = get xmlResponse //serviceGroupList
* match each serviceGroupListItems.serviceGroupList.serviceGroup == serviceGroupItem.serviceGroup