Reputation: 2038
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?
Upvotes: 3
Views: 1219
Reputation: 7395
XMLParser would be a better option as it allows for immediate feedback on the inserted nodes.
Upvotes: 0