空手道:匹配xml中的重复元素 [英] Karate: Match repeating element in xml
本文介绍了空手道:匹配xml中的重复元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试匹配xml中的重复元素以使模式空手道.
I'm trying to match a repeating element in a xml to karate schema.
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>
"""
我想将每个空手道模式都与之匹配
I want to match each with following karate schema
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
但是它不起作用.知道如何使它起作用
But it doesn't work. Any idea how can I make it work
推荐答案
您必须匹配每个serviceGroup.
You have to match each serviceGroup.
* xml serviceGroupListItems = get xmlResponse //serviceGroupList
* match each serviceGroupListItems.serviceGroupList.serviceGroup == serviceGroupItem.serviceGroup
这篇关于空手道:匹配xml中的重复元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文