groovy.util.slurpersupport.Node
을 groovy.util.Node
으로 변환하는 쉬운 방법이 있습니까?어떻게 신속하게 groovy.util.slurpersupport.Node를 인쇄합니까?
빠른 디버깅을 위해 XmlSlurper
에서 오는 노드에서 XmlNodePrinter
을 사용하려고합니다.
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '[email protected]' with class 'groovy.util.slurpersupport.Node' to class 'groovy.util.Node'
어떻게 신속 config
의 XML 표현을 인쇄 할 수 있습니다
def xml = new XmlSlurper().parse(new File(path + pomFile))
def services = xml.build.plugins.plugin.configuration.services
services.children().findAll{ it.artifactId.text() == serviceName }.each { config ->
// begin section to dump "config" for debugging
def stringWriter = new StringWriter()
new XmlNodePrinter(new PrintWriter(stringWriter)).print(config[0])
println stringWriter.toString()
// end section to dump "config" for debugging
// do some other processing on the config node
}
이이 (가) config[0]
행에 다음을 던졌습니다 : 여기 내 코드 (아마 가장 우아한)입니다?
Groovy 1.7.0으로 제한됩니다.
이 -
편집가 :
여기services.children().findAll{ it.artifactId.text() == serviceName }.each { config ->
println XmlUtil.serialize(config)
가 인쇄되어있는 작업은 다음과 같습니다 : 나는 또한 다음하지만 수신 오류 시도
[Fatal Error] :1:1: Content is not allowed in prolog.
ERROR: 'Content is not allowed in prolog.'
<?xml version="1.0" encoding="UTF-8"?>
groovy에서이 버그와 관련이 있습니까? https : //stackoverflow.com/questions/3151095/groovy-xmlutil-serialze-is-throwing-a-content-is-not-allowed-in-prolog-error – loteq