View Full Version : using JSP to extract data from XML

03-22-2004, 05:31 AM
consider the XML file given below:

<?xml version="1.0" encoding="ISO-8859-1"?>

<map id="1">D:\Webmap\usa.jpg</map>
<map id="1">D:\Webmap\euro.jpg</map>
<data id="1">D:\webmap\ker1.txt</data>
<data id="2">D:\webmap\ker2.txt</data>
<color id="1">Blue</color>
<color id="2">Yellow</color>
<color id="3">Green</color>

using HTML/Javascript, i have created a form from which user can select any one of the two jpg images, any one of the two text files and a color from the list of three colors.
i want to know if (1) the above XML file is correct and
(2) how can create a JSP page that interprets the above XML file and extracts only the selections made by the user
ie say for eg, the user has selected "usa.jpg", "ker1.txt" and "blue". for these selctions, how can i create a JSP/Servlet (pseude code is sufficient) that extracts the above mentioned data.
since i am new to JSP/Servlets, i am finding it difficult to proceed.
thanks in advance