Hmmm.
The best I have been able to come up with is actually pretty crappy...
///
import groovy.xml.DOMBuilder
import groovy.xml.dom.DOMCategory
import groovy.xml.XmlUtil
final CAR_RECORDS = '''
<records>
<car name='HSV Maloo' make='Holden' year='2006'>
<country>Australia</country>
<record type='speed'>Production Pickup Truck with speed of
271kph</record>
</car>
</records>
'''
def reader = new StringReader(CAR_RECORDS)
def doc = DOMBuilder.parse(reader)
def records = doc.documentElement
use (DOMCategory) {
def maloo = records.'car'[0]
assert maloo.'@name' == 'HSV Maloo'
maloo.replaceNode {
'comment' XmlUtil.serialize(maloo)['<?xml version="1.0"
encoding="UTF-8"?>'.size()..-1]
}
println XmlUtil.serialize(records).replaceAll('<comment>',
'<!--').replaceAll('</comment>', '-->')
}
///
There HAS to be a better way! Any Groovy Geniuses out there?
> -----Original Message-----
> From: Opal [mailto:
[hidden email]]
> Sent: Saturday, 31 August 2013 7:58 PM
> To:
[hidden email]
> Subject: [groovy-user] Re: How to comment/uncomment XML nodes?
>
> It seems to be better idea to prepare different xml files for various
purposes
> (if the nodes are too complex to handle them) and redesign the service to
> make use of an appropriate document.
>
> According to (un)commenting - no idea how to do it.
>
>
>
> --
> View this message in context:
http://groovy.329449.n5.nabble.com/How-to-> comment-uncomment-XML-nodes-tp5716682p5716694.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>
http://xircles.codehaus.org/manage_email>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email