}\r
return nodes\r
}\r
+ /**\r
+ * Note: this uses XmlParser instead of XmlSlurper, thus it is not as\r
+ * efficient because it instantiates the whole DOM tree.\r
+ * @param xmlInput\r
+ * @param element\r
+ * @return a list of Nodes, or {@code null} if <i>xmlInput</i> is {@code null}\r
+ */\r
+ def getMultNodeObjects(xmlInput, element){\r
+ def nodes=null\r
+ if(xmlInput!=null){\r
+ def xml= new XmlParser().parseText(xmlInput)\r
+ nodes = xml.'**'.findAll{ node-> node.name() == element }\r
+ }\r
+ return nodes\r
+ }\r
def getNodeText1(xmlInput,element){\r
def rtn=null\r
if(xmlInput!=null){\r
\r
return requestId\r
}\r
+\r
+ /**\r
+ * Remove all the empty nodes and attributes from the within the given node\r
+ * @param node\r
+ * @return true if all empty nodes and attributes were removed.\r
+ */\r
+ public boolean cleanNode( Node node ) {\r
+ node.attributes().with { a ->\r
+ a.findAll { !it.value }.each { a.remove( it.key ) }\r
+ }\r
+ node.children().with { kids ->\r
+ kids.findAll { it instanceof Node ? !cleanNode( it ) : false }\r
+ .each { kids.remove( it ) }\r
+ }\r
+ node.attributes() || node.children() || node.text()\r
+ }\r
+\r
+ /**\r
+ *\r
+ * @param xml\r
+ * @return String representation of xml after removing the empty nodes and attributes\r
+ */\r
+ public String cleanNode(String xmlString) {\r
+ def xml = new XmlParser(false, false).parseText(xmlString)\r
+ cleanNode(xml)\r
+ return XmlUtil.serialize(xml)\r
+ }\r
}\r