I am just seeing if this is feasible and maybe get a small code example if possible. Is it possible to make a JSP page that parses an XML file that is stored on the server.
The XML will contain the elements displayed on the page therefore changing the XML can alter the look / layout of the JSP page.
I am not sure how I would format the XML though and call it into the JSP, if anyone knows a resource or whether that is possible it would be a lot of help (I’m not expecting someone to just do something for me ;))
Thanks
Yes, it is possible, though, why do not you use XSLT? if your main aim is transforming, then XSLT will do the job for you without JSP. If not, then your implementation is specific to the Java Server Pages domain, and when you decide to change the server let’s say to PHP, then you will have to reprogram the whole thing.
If you want an simple example on how to transform an XML data using java, take a look at the following xml stored in ‘data.xml’
you can read this file using XDom, JDom, or what have you. I will use the basic DOM included in java which is not so friendly and lack iterators, indeed not recommended for large XML files.
the html output would be: