XPath 设置多个值

XPath to set multiple values

在下面的消息中,我想将 2 'invunique' 个节点设置为参数 vParam。 我可以使用

轻松设置 'cvalue'
xpath(MyMsg.Body, "//*[local-name()='cvalue']") = vParam;

但我还没有找到在 1 个 XPath 语句中设置 2 个 'invunique' 节点的好方法,有什么想法吗?

<ns0:newcase xmlns:ns0="http://MyNamespace/v1-0">
<ns0:caseheader>
  <ns0:caseunique>10</ns0:caseunique> 
</ns0:caseheader>
<ns0:financials>
 <ns0:invoices>
   <ns0:invoice>
       <ns0:caseunique>10</ns0:caseunique> 
       <ns0:invunique>10</ns0:invunique> 
       <ns0:invudfs>
         <ns0:invudf>
           <ns0:invunique>20</ns0:invunique> 
           <ns0:cvalue>cvalue_0</ns0:cvalue> 
           <ns0:otherdesc>otherdesc_0</ns0:otherdesc> 
         </ns0:invudf>
       </ns0:invudfs>
  </ns0:invoice>
 </ns0:invoices>
</ns0:financials>
</ns0:newcase>

据我所知(遗憾的是我还没有测试过),xpath 函数 'setter' 将只能更新第一个匹配项。如果您有第二个 cvalue 节点,则只会更新第一个。

为什么您希望在一个语句中同时更新而不是有 2 个语句?

如果这是一个循环节点,我建议改用映射或助手 class。