Import XML into a Grails Domain Class

后端 未结 1 1004
野趣味
野趣味 2020-12-10 00:31

I am reading an XML file with a schema based on a Domain Class.

Here is a simple example for illustration (my current situation concerns a lot of fields from a lot o

相关标签:
1条回答
  • 2020-12-10 01:22

    Actually, you can give directly the list of attributes to your domain class constructor with attributes().

    def players = new XmlSlurper().parse(xmlFile)
    players.player.each() {p ->
        new Player(p.attributes()).save()
    }
    
    0 讨论(0)
提交回复
热议问题