Created
February 29, 2012 02:43
-
-
Save ponkichi7/1937155 to your computer and use it in GitHub Desktop.
GroovyでXML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.xml.MarkupBuilder | |
def writer = new StringWriter() | |
def xml = new MarkupBuilder(writer) | |
xml.example() { | |
person(name: 'hoge', type: 'hage'){ | |
city('Tokyo') | |
remarks('特に無し') | |
} | |
person(name: 'moge', type: 'debu', foo: 'bar'){ | |
city('Saitama') | |
remarks('だ埼玉って言わないで') | |
} | |
} | |
def doc = new XmlSlurper().parseText(writer.toString()) | |
println "city=${doc.person.find { it.@type == 'debu' }.city}" | |
出力結果: | |
city=Saitama |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment