-1

I have object has XML as a string. For example I have a domain which has

class person{
    String personId
    String personName
    String personType
    String personDescription
    String personDetailsXML
}

I am getting the details and binding to person object. I have to pass this object to another controller which displays the info about each person when he clicks on the profile name. How do i parse the XML string.

I have another domain say eachPerson domian which has

class eachPerson{
 String personName
 String personDescription
 Object personDetails

I want to match the person name and person description and persondetailsXml.How do I do that and how can I parse personDetailsXML to personDetails object. Please suggest. How i can pass the personInstance as object to action show() in eachPerson controller??

4

2 回答 2

1

I'd check this out for starters. Should be pretty straightforward to work from this example.

http://groovy.codehaus.org/Reading+XML+using+Groovy%27s+XmlParser.


(Upon re-reading, this doesn't entirely answer the question...)

于 2012-04-22T23:31:19.313 回答
0

You need to parse the xml (using introduced in the link in the comment above - or with XmlSlurper). This is pretty straightforward and easy to understand. If you have all the data you can use render(action:'show', controller:'eachPerson', model:[persons:personsData]). See the grails doc for further details how to use render.

This will call the action with the given data. In the show action you can access it with params.persons.

于 2012-04-23T18:38:26.333 回答