Ich habe einfache Entität in Webapp von Play Framework gesteuert. Es sieht wie folgt aus:Play Framework: Pars XML zu Modell
case class MyItem(id: Option[Long] = None, name: String, comments: List[Comment])
case class Comment(commentDate: Date, commentText: String)
Und ich bekomme die XML-Daten aus DB, der wie folgt aussieht:
<?xml version="1.0"?>
<item>
<id>1</id>
<name>real item</name>
<comments>
<comment>
<comment_date>01.01.1970</comment_date>
<comment_text>it rocks</comment_text>
</comment>
<comment>
<comment_date>02.01.1970</comment_date>
<comment_text>it's terrible</comment_text>
</comment>
</comments>
</item>
Und jetzt habe ich keine Ahnung, mit ihm zum Modell und Form-Mapping-Parsing.
Meine Form Mapping für alle Fälle (nicht kompiliert jetzt):
val itemForm = Form(
mapping(
"id" -> optional(longNumber),
"name" -> nonEmptyText,
"comments" -> list(mapping(
"commentDate" -> date("dd.mm.yyyy"),
"commentText" -> text
)(Comment.apply)(Comment.unapply))
)(MyItem.apply)(MyItem.unapply)
)