XmlSlurper parsing a query result

I have a query that bring back a cell in my table the has all xml in it. I have it so I can spit out what is in the cell without any delimiters. Now i need to actually take each individual element and link them with my object. Is there any easy way to do 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 from DEV.AUDIT_LOG T WHERE XMLEXISTS(\'\$s/*/user[id=\"' + id + '\" or username=\"'+username+'\"]\' passing T.AUDIT_DETAILS as \"s\") ORDER BY AUDIT_EVENT', []) { ResultSet rs ->
        while (rs.next()) { 
            def auditDetails = new XmlSlurper().parseText(rs.getString('AUDIT_EVENT_DETAILS'))
            println auditDetails.toString

now this will give me that cell with those audit details in it. Bad thing is that is just puts all the information from the field in on giant string without the element tags. How would I go through and assign the values to a object. I have been trying to work with this example http://gallemore.blogspot.com/2008/04/groovy-xmlslurper.html with no luck since that works with a file.

I have to be missing something. I tried running another parseText(auditDetails) but haven't had any luck on that.

Any suggestions?


The xml int that field looks like

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

^ simular to how it is except mine is ALOT longer. It comes out as "scottsmithtue 5th 2009" so on and so forth. I need to actually take those tags and link them to my object instead of just printing them in one conjoined string.


Just do




To access the properties you require

Need Your Help

C++ exception not caught in XCode iOS project

c++ objective-c xcode exception

I created a C++ library. I am using it in an iOS application. I thought of handling exceptions in C++ library and in order to test this I created a test scheme and called the c++ function from it. ...

Android check is valid UUID

android uuid

Is there a way that I can check if a string is a valid UUID?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.