I believe this method also works.
<xmltask source="shared.xml" dest="shared.xml" outputter="simple:3"> <copy path="/sharedobjects/connection[name/text()='MY CONNECTION']/name/text()" property="XML_EXISTS_ALREADY" /> <insert path="/sharedobjects[last()]" unless="XML_EXISTS_ALREADY"> <![CDATA[ <connection> <name>MY CONNECTION</name> </connection> ]]> </insert> </xmltask>
NOTE. The xmltask copy task allows you to store attributes or text nodes in properties. Thus, you must specify /name/text() at the end of the path argument for <copy> (even if we really care about the whole <connection> node, and not its child text).
source share