I am evaluating certain conditions sent by a jsp page and sending the ajax response in the format as shown below.
//Part of the response
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
response.getWriter().write("<valid>true</valid>");
I the above shown code portion i return a value true in the xml tag valid how do i return more than one piece of information in another xml tag in the same response.
I tried adding a new xml tag but it wouldn’t work.
response.getWriter().write("<valid>true</valid><name>dave</name>");
How can i return more than one piece of information in this format.
Currently its working fine if I am returning only one piece of information using the tag valid whose value is being used in the javascript code as follows.
var msg = responseXML.getElementsByTagName("valid")[0].firstChild.nodeValue;
What changes do i need to do here if i want to access the second peiece of information returned in the second xml tag.
A XML document can have only one root element but yet you’re attempting to write multiple root elements. You need to invent one common root element and use it for all XML documents. For example,
<data>or<response>or whatever you like.See also: