我通过从请求 xml 中读取父 xml 来构建父 xml 下面是代码:
def createXML(requestXML)
{
def formXML = new XmlSlurper().parseText(requestXML)
def formMap = [:]
formXML.children.each {
formMap[it.name()] = it
}
buildComponentXML(formMap)
}
def buildComponentXML(formMap)
{
def compXML = formMap['componentName']
def anotherNode = new Node (compXML, 'AnotherNode',1234555)
println XmlUtil.serialize(compXML)
}
例外
Could not find matching constructor for: groovy.util.Node(groovy.util.slurpersupport.NodeChild, java.lang.String, java.lang.String)