Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.7.3
-
None
Description
The following gives an error:
import groovy.xml.XmlUtil import groovy.xml.StreamingMarkupBuilder def xmlStr = """<?xml version="1.0" encoding="UTF-8"?> <stuff ver="1.0"> <properties> <foo>bar</foo> </properties> </stuff>""" def gpr = new XmlSlurper().parseText( xmlStr ) println XmlUtil.serialize( gpr )
Gives the following error:
[Fatal Error] :1:1: Content is not allowed in prolog. ERROR: 'Content is not allowed in prolog.' <?xml version="1.0" encoding="UTF-8"?>
However if we change the println to:
println XmlUtil.serialize( (groovy.util.slurpersupport.GPathResult)gpr )
We get the correct output:
<?xml version="1.0" encoding="UTF-8"?> <stuff ver="1.0"> <properties> <foo>bar</foo> </properties> </stuff>
Looks like Groovy is picking the wrong method somewhere... (though I can't see how)