bhatnk
(Kartik Bhatnagar)
May 29, 2015, 6:09pm
1
I want to be able to modify the element/node value based on the value using webXml{ }.
Here is a sample of the xml I am working with:
fileName.war
specifiedContextRoot
fileName2.war
specifiedContextRoot
Based on the different fileName values for “web-uri”, I need to change the value of the “context-root” - how can I do this using withXml { }? The xml file is automatically generated through gradle
thanks for any help in advance.
bmuschko
(Benjamin Muschko)
May 29, 2015, 7:13pm
2
Could you please properly format your XML example code? It’s hard to propose pseudo code if you don’t know what your XML structure looks like.
bhatnk
(Kartik Bhatnagar)
May 29, 2015, 7:51pm
4
Sorry, didn’t realize it didn’t take the entire file, here is what the generated application.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" id="Application_ID" version="6">
<display-name>TestApp</display-name>
<module>
<web>
<web-uri>TestApp.war</web-uri>
<context-root>customized/text</context-root>
</web>
</module>
<module>
<web>
<web-uri>TestApp.war</web-uri>
<context-root>customized/text</context-root>
</web>
</module>
</application>
bmuschko
(Benjamin Muschko)
May 29, 2015, 8:12pm
5
You are basically navigating a hierarchy of groovy.util.Node s. when using withXml
. You can find out how to work with XML processing in Groovy in their documentation.