4

我有一个正在转换的配置文件:

<?xml version="1.0" encoding="utf-8"?>
<TopNode>
  <Sub>
    <subnode>aaaa</subnode>
    <othernode>sdfsfsdfsd</othernode>
  </Sub>
  <Sub>
    <subnode>aaaa</subnode>
    <othernode>iiiiiii</othernode>
  </Sub>
  <Sub>
    <subnode>aaaa</subnode>
    <othernode>blahblahblahblabhlahb</othernode>
  </Sub>
  <Sub>
    <subnode>aaaa</subnode>
    <othernode>sdfsdfseeferererer</othernode>
  </Sub>  
</TopNode>

我有这个变换:

<?xml version="1.0" encoding="utf-8" ?>
<TopNode xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <Sub>
    <subnode xdt:Transform="Replace">replaceallwiththis</subnode>
  </Sub>
</TopNode>

它只替换第一个子节点匹配。我如何让它全部替换?

我也尝试这样但没有工作:

<subnode xdt:Locator="Condition(.)" xdt:Transform="Replace">replaceallwiththis</subnode>

我也尝试过,但她没有工作(仅替换第一场比赛):

<subnode xdt:Locator="XPath(//TopNode/Sub[subnode='aaaa']/subnode)" xdt:Transform="Replace">zzzzzzzzzzzzzzzzzzz</subnode>
4

0 回答 0