Displaying the data in the grid using the following method call
mygrid.loadXML("…/filename.xml");
This xml file is created at the server side when a checkbox is selected, the client picks it up and displays it in the grid.Its producing
Error Type:LoadXML
Description:Incorrect XML
LoadXML error is generated ONLY when its tested on remote link,but not while the code is run localy on machine.Thought many possibilities,like timing issue,finally it seems that file is not even created.
=>the file creation process is as follows
private void fileCreation(ArrayList nameList)
{
try {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document doc = documentBuilder.newDocument();
Element root = doc.createElement(“rows”);
doc.appendChild(root);
int count = 0;
Iterator itr = nameList.iterator();
while (itr.hasNext())
{ xxxDTO obj = (xxxDTO)itr.next();
if("".equals(obj.getNo().trim()) && “”.equals(obj.getName().trim()))
{ continue; }
count++;
Element childElement = doc.createElement(“row”);
childElement.setAttribute(“id”,""+count);
root.appendChild(childElement);
Element rowChildElement = doc.createElement(“cell”);
childElement.appendChild(rowChildElement);
rowChildElement.appendChild(doc.createTextNode(“0”));
Element rowChildElement2 = doc.createElement(“cell”);
childElement.appendChild(rowChildElement2);
rowChildElement2.appendChild(doc.createTextNode(obj.getNo()));
Element rowChildElement3 = doc.createElement(“cell”);
childElement.appendChild(rowChildElement3);
rowChildElement3.appendChild(doc.createTextNode(obj.getName()));
}
TransformerFactory tranFactory = TransformerFactory.newInstance();
Transformer aTransformer = tranFactory.newTransformer();
Source src = new DOMSource(doc);
String fileLoc = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
if(fileLoc.indexOf(“WEB-INF”) != -1)
{ fileLoc = fileLoc.substring(0,fileLoc.indexOf(“WEB-INF”)); }
File file = new File(fileLoc+"/filename.xml");
Result dest = new StreamResult(file);
aTransformer.transform(src, dest);
}
catch (FactoryConfigurationError fce)
{ System.out.println(“Cannot get the DocumentBuilderFactory instance: " + fce.getMessage()); }
catch (ParserConfigurationException pce)
{ System.out.println(“Cannot get the DocumentBuilder instance” + pce.getMessage()); }
catch(Exception e)
{ System.out.println(e.getMessage()); }
}
=>parsed using a jsp file
Can u pls help to fix why loadXML error is thrown in this case