문제

I understand that XML document changes are not immediate when using Groovy's XMLSlurper and StreamingMarkupBuilder. However, I'm not happy having to do a lot of processing whenever I change a document. The only way I've gotten it to work is if I do this:

    ...
labDoc = new XmlSlurper().parseText(serializeXml(labDoc))
...
def String serializeXml(GPathResult xml){
XmlUtil.serialize(new StreamingMarkupBuilder().bind {
        mkp.declareNamespace("lab", "www.myco.com/LabDocument")
        mkp.yield labDoc
  } )
}

every time I append a new Node. There has to be a better way! Can anyone help?

도움이 되었습니까?

해결책

XMLParser would be a better option as it allows for immediate feedback on the inserted nodes.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top