Hi, I have an XML file, eg. <cd> <name>a</name> <name>b</name> ... </cd>
my jsp page want to list all the cd names. Before each name, there will be a checkbox to let user select.
After select, user click save button, then modify the XML by adding an attribute to each <name> element to indicate whether selected.
How can I do this? My current thought is to parse the XML, and find out all the names first before come into this page. Then display all the names. After submit, modify the XML accordingly. Is there any other way to do it?
There is no direct struts benefit to doing what you're trying to do. It may, however, be a little easier if you change your xml into an actual ActionForm class that could provide an easier interface into posting from your form and doing the processing of the XML in the background (before it ever reaches your eventual Action).
I'm with Michael. I like to do things as simple as possible. Manipulating it as XML in the JSP sounds hard. The usual way to do things in Struts is to put JavaBean in the request, so why not do that. I recommend you use the Apache Digester to turn your XML into JavaBeans from inside the Struts Action.