嗨,我正在尝试替换结构第二层中的一个节点,例如下面的“两个”节点(我想复制该节点及其子节点)
<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>
这样它最终看起来像这样:
<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>
这在空手道有可能吗?
非常感谢
答案 0 :(得分:2)
通常,我不建议“太聪明”的测试-每个Scenario
都应集中在一个“静态”有效载荷上-当您稍后尝试阅读测试时,您将感激不尽。
还要确保您查看了以下有关“模板化”想法的示例:xml.feature
但是无论如何,你去了
* 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