grails - XmlSlurper parsing a query result -


i have query bring cell in table has xml in it. have can spit out in cell without delimiters. need take each individual element , link them object. there easy way this?

    def sql     def datasource     static transactional = true     def pulllogs(string username, string id) {      if(username != null && id != null) {      sql = new sql(datasource)     println "data source is: " + datasource.tostring()     def schema = datasource.properties.defaultschema      sql.query('select userid, audit_details dev.audit_log t xmlexists(\'\$s/*/user[id=\"' + id + '\" or username=\"'+username+'\"]\' passing t.audit_details \"s\") order audit_event', []) { resultset rs ->         while (rs.next()) {              def auditdetails = new xmlslurper().parsetext(rs.getstring('audit_event_details'))             println auditdetails.tostring         }     }     sql.close()   } } 

now give me cell audit details in it. bad thing is puts information field in on giant string without element tags. how go through , assign values object. have been trying work example http://gallemore.blogspot.com/2008/04/groovy-xmlslurper.html no luck since works file.

i have missing something. tried running parsetext(auditdetails) haven't had luck on that.

any suggestions?

edit:

the xml int field looks

<user><username>scottsmith</username><timestamp>tues 5th 2009</timestamp></user> 

^ simular how except mine alot longer. comes out "scottsmithtue 5th 2009" on , forth. need take tags , link them object instead of printing them in 1 conjoined string.

just do

auditdetails.username 

or

auditdetails.timestamp 

to access properties require


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -