0
對於列表中的每個元素,xml任務是否可以將一個節點的值複製到另一個節點中?使用xmltask將一個值複製到另一個值
源XML:
<a>
<b>
<c1>foo</c1>
<c2></c2>
</b>
<b>
<c1>bar</c1>
<c2></c2>
</b>
...
</a>
目標XML:
<a>
<b>
<c1>foo</c1>
<c2>foo</c2>
</b>
<b>
<c1>bar</c1>
<c2>bar</c2>
</b>
...
</a>
我試圖完成上述在我的螞蟻的任務,但我續似乎找到一個方法來做到這一點,這裏是我到目前爲止,
<target name="mergefile">
<!-- Read the source into a buffer -->
<xmltask source="source.xml" clearBuffers="list">
<copy path="/a" buffer="list" append="true"/>
</xmltask>
<!-- Write them to the output -->
<xmltask source="destination.xml" dest="destination.xml"
outputter="simple">
<!-- First clear all the old paths. -->
<remove path="https://stackoverflow.com/a/b"/>
<!-- Then add the resolved ones. -->
<paste path="/a" buffer="list"></paste>
<!-- Copy the value over? -->
<replace path="a/b/c2/text()" withText="No Idea"/>
</xmltask>
</target>
任何想法如何將值從一個節點複製到下一個所有元素在列表中的ts?
是destination.xml在這個例子中最初是空的? – 2012-01-11 21:07:15
@Brian它有'...'我試圖用source.xml中的路徑替換'a'節點的內容。 – Andrew 2012-01-11 21:13:06