I am trying to insert a node into an existing XML document. I use groovy and ANT for that.
So does my XML look like:
<root>
<node1 db="a"
user="test"/>
</root>
Within this XML file I have a groovy section that looks that way:
My groovy script, embedded in the ANT xml file.
<target name="some-target">
<script language="groovy">
def fragment = '''<root>
<node1 db="a"
user="test"/>
</root>''';
def parser = new XmlParser();
xml.appendNode{fragment};
def xmlOutput = new StringWriter();
def xmlNodePrinter = new XmlNodePrinter(new PrintWriter(xmlOutput));
xmlNodePrinter.print(xml);
Now, I just want to add a second node, but I do not how to achieve that?
If I add now a second node I always get the following output in the result:
<root>
<node1 db="a"
user="test"/>
<Script1$_run_closure2@451001e5/>
</root>
Thank you for your help in advance!