Skip to content

Instantly share code, notes, and snippets.

@osima
Created June 3, 2010 01:34
Show Gist options
  • Save osima/423299 to your computer and use it in GitHub Desktop.
Save osima/423299 to your computer and use it in GitHub Desktop.
XML文書をコンパクト形式に変換
//
// [使い方]
// groovy -c UTF-8 -i src.xml -o compact.xml
//
// [機能]
// src.xml のインデント・改行等を削除してコンパクト形式に変換する/Pretty形式にも変換可能
//
// [依存]
// - jdom.jar
// - CmdProc.groovy
//
import org.jdom.input.*
import org.jdom.output.*
def ENC = 'UTF-8'
def cmdp = new CmdProc(args)
def doc = new SAXBuilder().build( cmdp.inputFile )
def w = cmdp.outputFile.newWriter('UTF-8')
//def xmlout = new XMLOutputter( Format.getPrettyFormat() )
def xmlout = new XMLOutputter( Format.getCompactFormat() )
xmlout.output(doc,w)
w.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment