Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5158

Encoding issue with groovy.xml.XmlUtil.serialize()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.8.2
    • 2.0-beta-3, 1.8.7
    • None
    • None

    Description

      http://groovy.329449.n5.nabble.com/Encoding-issue-with-groovy-xml-XmlUtil-serialize-td5038513.html

      I think it should be possible to put an 'ü' charter in the xml element.

      def xml ="""<?xml version="1.0" encoding="UTF-8"?>
      <Schlüssel>
      text content
      </Schlüssel>"""

      groovy.util.slurpersupport.GPathResult s = new XmlSlurper().parseText(xml)

      println groovy.xml.XmlUtil.serialize(s) // results in empty xml, why?

      ----- OUTPUT
      <?xml version="1.0" encoding="UTF-8"?>

      WORKAROUND
      def outxml = new groovy.xml.StreamingMarkupBuilder().with {
      encoding = 'UTF-8'
      '<?xml version="1.0" encoding="UTF-8"?>\n' + bindNode( s )
      }
      println outxml

      Attachments

        Activity

          People

            paulk Paul King
            citron Anders
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: