Question

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?

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top