【问题标题】:XPath to set multiple valuesXPath 设置多个值
【发布时间】:2016-04-27 14:49:14
【问题描述】:

在下面的消息中,我想将 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>

【问题讨论】:

    标签: xml xpath biztalk biztalk-2013


    【解决方案1】:

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

    您为什么希望在一个语句中更新两个语句而不是两个语句?

    如果这是一个循环节点,我建议使用映射或辅助类。

    【讨论】:

    • 我想 2 语句会做到这一点。我正在使用 c# 实用程序来设置变量,然后想要使用变量来更新消息而不需要地图。请问xpath的结构是什么来设置第二个invunique值?
    猜你喜欢
    • 2023-01-13
    • 1970-01-01
    • 1970-01-01
    • 2014-04-10
    • 2014-10-23
    • 2014-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多