javascript - How to change XML attribute on the client side and then save the result on the server side? -
My question is:
I read an XML file from server side and then call them client On the side I present, I want to edit the data, like: method to change them using setAttribute () now comes the problem here: I just do not want to modify them on the client side, but also on the server side , And save them the XML file. How can I use JSP and Javascript? Here are some initial ideas, but some part is not working ... like the line: "% count%" = length; "
And I think this is actually slowing page loads if I write the XML line by line ... is it better to do this?
Thank you :)
& lt;% string attribute []; integer number; & Gt%; & Lt; Script & gt; // hide the section of xmlDoc var length = xmlDoc.getElementsByTagName ("item") to read the XML file. Length; & Lt;% count% & gt; = Length; // it does not work ... ??? (Int i = 0; i & lt; length; i ++) {xmlDoc.getElementsByTagName ("item") Item [i] .setAttribute ("score", "1"); & Lt;% attribute [i]% & gt; = XmlDoc.getElementsByTagName ("item"). Item [i] .setAttribute ("score"); } & Lt; / Script & gt; & Lt;% string xmlString; String person nm = {"bob", "mike", "lily"}; (Int i; i; l; count; i ++) xmlString = "person score =" + attribute [i] + "& gt; person nm [i] ; // Here I use the Out Buffer to print the line from the line ... outputfile = new file ("result.xml"); OutputFile.createNewFile (); Flamewriter Outfile = New Flameritter (Output File); Outfile.write (xmlString); Outfile.close (); & Gt%; You must understand that JSP is executed on the server . Only JSP on the server is executed and results are sent to the server. What your customer will get is the following:
& lt; Script & gt; Read the xml file for // xmlDoc var length = xmlDoc.getElementsByTagName ("item"). Length; = Length; (Int i = 0; i & lt; length; i ++) {xmlDoc.getElementsByTagName ("item") Item [i] .setAttribute ("score", "1"); = XmlDoc.getElementsByTagName ("item"). Item [i] .setAttribute ("score"); } & Lt; / Script & gt; Note that the result of all the JSP tags and browsers executed on the server is the result. No Javascript is executed on the server . What you probably want to do is to modify your XML on the server and as a result, return results in the page.
Comments
Post a Comment