Akarui_Tomodach
17 years agoOccasional Contributor
PLEASE HELP !!!: How to append "repetition" of nodes ?
PLEASE HELP !!!!
How to append (insert) element repetition in the default request file ?
I have a "default request" as below:
/******************* Default request before repeat ***************************
xmlns:prod1="http://xyz.ca/ebusiness/ProductService">
?
****************************************************************************/
Now, I need to insert (repeatedly) the element "ProductServiceId" 3 times which will look like:
/******************* Default request after repeat inserted *****************
xmlns:prod1="http://xyz.ca/ebusiness/ProductService">
?
?
?
****************************************************************************/
How can I do it in Groovy ?
I have tried as below, but it is giving me an exception (I know, did something wrong )
"Mon May 26 02:32:18 EDT 2008:ERROR:groovy.lang.MissingMethodException: No signature of method: groovy.util.NodeList.appendNode() is applicable for argument types: (java.lang.String, java.lang.String) values: {"prod1:ProductServiceId", "?"}"
My code snippet is:
/********************
...
...
def root = new XmlParser().parseText(newRequest)
root["soapenv:Body"]["prod:getDistProductDetails"]["prod:request"]["prod1:ProdSet"].appendNode("prod1:ProductServiceId", "?")
def writer = new StringWriter()
new XmlNodePrinter(new PrintWriter(writer)).print(root)
def result = writer.toString()
...
...
********************/
How to append (insert) element repetition in the default request file ?
I have a "default request" as below:
/******************* Default request before repeat ***************************
xmlns:prod1="http://xyz.ca/ebusiness/ProductService">
****************************************************************************/
Now, I need to insert (repeatedly) the element "ProductServiceId" 3 times which will look like:
/******************* Default request after repeat inserted *****************
****************************************************************************/
How can I do it in Groovy ?
I have tried as below, but it is giving me an exception (I know, did something wrong )
"Mon May 26 02:32:18 EDT 2008:ERROR:groovy.lang.MissingMethodException: No signature of method: groovy.util.NodeList.appendNode() is applicable for argument types: (java.lang.String, java.lang.String) values: {"prod1:ProductServiceId", "?"}"
My code snippet is:
/********************
...
...
def root = new XmlParser().parseText(newRequest)
root["soapenv:Body"]["prod:getDistProductDetails"]["prod:request"]["prod1:ProdSet"].appendNode("prod1:ProductServiceId", "?")
def writer = new StringWriter()
new XmlNodePrinter(new PrintWriter(writer)).print(root)
def result = writer.toString()
...
...
********************/