使用 groovy 脚本复制 xml 命名空间节点
Replicating a xml namespace node using groovy script
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.datapower.com/schemas/appliance/management/3.0">
<soapenv:Header/>
<soapenv:Body>
<ns:QuiesceRequest>
<ns:Domain>
<ns:Name></ns:Name>
<ns:Timeout></ns:Timeout>
<ns:Services>
<!--Zero or more repetitions:-->
<ns:Object name="" class-name="" class-display-name=""/>
enter tag here
enter tag here
enter tag here
</ns:Services>
</ns:Domain>
</ns:QuiesceRequest>
</soapenv:Body>
我需要多次添加以下标签:
待添加标签=>
ns:Object name="" class-name="" class-display-name=""
类似于上面显示的标签"enter tag here"
里面XML:
谁能告诉我如何在 groovy 脚本中实现这一点?
我尝试了一些脚本,但没有达到预期的效果。
我不确定脚本是什么,它不起作用。您可以简单地在整个 ns:Services 标记下设置 groovy 响应,在脚本中添加必要数量的节点并循环到 groovy return 对象,如下所示:
<ns:Services>${SomeGroovyScript#result}</ns:Services>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.datapower.com/schemas/appliance/management/3.0">
<soapenv:Header/>
<soapenv:Body>
<ns:QuiesceRequest>
<ns:Domain>
<ns:Name></ns:Name>
<ns:Timeout></ns:Timeout>
<ns:Services>
<!--Zero or more repetitions:-->
<ns:Object name="" class-name="" class-display-name=""/>
enter tag here
enter tag here
enter tag here
</ns:Services>
</ns:Domain>
</ns:QuiesceRequest>
</soapenv:Body>
我需要多次添加以下标签:
待添加标签=>
ns:Object name="" class-name="" class-display-name=""
类似于上面显示的标签"enter tag here"
里面XML:
谁能告诉我如何在 groovy 脚本中实现这一点?
我尝试了一些脚本,但没有达到预期的效果。
我不确定脚本是什么,它不起作用。您可以简单地在整个 ns:Services 标记下设置 groovy 响应,在脚本中添加必要数量的节点并循环到 groovy return 对象,如下所示:
<ns:Services>${SomeGroovyScript#result}</ns:Services>