Api 如何在空手道中复制节点及其子节点

Api 如何在空手道中复制节点及其子节点,api,testing,cucumber,karate,Api,Testing,Cucumber,Karate,嗨,我试图替换结构第二层中的一个节点,例如下面的“两个”节点(我想复制这个节点及其子节点) 1. 1. A. B C C 3. 所以它最终看起来像这样: <root> <first>1</first> <second> <one>1</one> <two> <a>a</a> <b>b</b>

嗨,我试图替换结构第二层中的一个节点,例如下面的“两个”节点(我想复制这个节点及其子节点)


1.
1.
A.
B
C
C
3.
所以它最终看起来像这样:

<root>
   <first>1</first>
   <second>
      <one>1</one>
      <two>
         <a>a</a>
         <b>b</b>
         <c>c</c>
      </two>
      <two>
         <a>a</a>
         <b>b</b>
         <c>c</c>
      </two>
      <three>c</three>
   </second>
   <third>3</third>
</root>

1.
1.
A.
B
C
A.
B
C
C
3.
空手道能做到这一点吗


非常感谢

通常我不推荐“太聪明”的测试-每个
场景
都应该关注一个“静态”负载-稍后当您尝试阅读测试时,您会感谢自己

另外,请务必查看这组“模板化”想法的示例:

但不管怎样,给你:

* def root =
"""
<root>
   <first>1</first>
   <second>
      <one>1</one>
      <two>
         <a>a</a>
         <b>b</b>
         <c>c</c>
      </two>
      <three>c</three>
   </second>
   <third>3</third>
</root>
"""
* xmlstring two = $root/root/second/two
* replace root.<three>c</three> = two + '<three>c</three>'
* xml root = root
* print root
*定义根目录=
"""
1.
1.
A.
B
C
C
3.
"""
*xmlstring two=$root/root/second/two
*替换根目录。c=2+c
*xml root=root
*打印根

Hi@Peter Thomas,感谢您的回答,我请求的结构相对复杂,因此我试图简化代码。还有一个问题,如果“三个”节点包含多个子节点,比如几十个子节点,该怎么办?替换时是否需要键入所有子节点?@Jackson视情况而定。我必须承认XML有局限性,我怀疑在任何其他框架中都不能做得更好。我提出了其他选择。我真的认为你的测试方法和测试数据并不理想。
* def root =
"""
<root>
   <first>1</first>
   <second>
      <one>1</one>
      <two>
         <a>a</a>
         <b>b</b>
         <c>c</c>
      </two>
      <three>c</three>
   </second>
   <third>3</third>
</root>
"""
* xmlstring two = $root/root/second/two
* replace root.<three>c</three> = two + '<three>c</three>'
* xml root = root
* print root