Created
January 7, 2013 02:41
-
-
Save kimukou/4471881 to your computer and use it in GitHub Desktop.
simple-xml-test
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
//see http://tatete.blogspot.jp/2012/01/androidxml.html | |
// http://tatete.blogspot.jp/2012/01/androidxml_18.html | |
// | |
@Grab('org.simpleframework:simple-xml:2.6.9') | |
import org.simpleframework.xml.Element | |
import org.simpleframework.xml.Root | |
import org.simpleframework.xml.core.Persister | |
@Root | |
public class Book { | |
@Element | |
public String name; | |
@Element | |
public String author; | |
@Element | |
public int price; | |
} | |
String str = """ | |
<book> | |
<name>aaa</name> | |
<author>杵渕 聡</author> | |
<price>2300</price> | |
</book> | |
""" | |
StringReader is = new StringReader(str.toString()); | |
Persister persister = new Persister(); | |
Book book = persister.read(Book.class, is); | |
println "book.name " + book.name | |
println "book.author " + book.author | |
println "book.price " + book.price |
Gist様
こんにちは!
今日にはKosuke Kawadaと申します。
投稿拝見させていただきました。完成度が高いですね。
Java関連のことでいくつが伺いたいことがあります、ご連絡いただくことは可能ですか?
こちらのアドレスにご連絡ください!
[email protected]
ご連絡お待ちしております。
Kawada
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DASH