我希望能够从XML文件中提取数据并将其反映在其他网页上。数据的位置应该与保存的位置完全相同。
<%
FileWriter fw = new FileWriter ( request.getRealPath("/") + "conf/taskcard2.xml", false);
BufferedWriter br = new BufferedWriter ( fw);
PrintWriter pw = new PrintWriter ( br);
pw.println ( "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" );
pw.println ( "<TemplateEditor>");
String value = request.getParameter("movableItems");
String[] items = value.split("\\|");
int size = items.length;
for (int i=0; i<size; i++) {
String[] data = items[i].split(",");
pw.println ( "\t<Logo>");
pw.print ( "\t\t<Number>"); pw.print (Integer.valueOf(data[0])+1); pw.println ( "</Number>");
pw.print ( "\t\t<X_Coord>"); pw.print (data[1]); pw.println ( "</X_Coord>");
pw.print ( "\t\t<Y_Coord>"); pw.print (data[2]); pw.println ( "</Y_Coord>");
pw.print ( "\t\t<Width>"); pw.print (data[3]); pw.println ( "</Width>");
pw.print ( "\t\t<Height>"); pw.print (data[4]); pw.println ( "</Height>");
pw.println ( "\t</Logo>");
}
pw.println ( "</TemplateEditor>");
pw.flush();
pw.close();
br.close();
fw.close();
%>