Refer this tutorial:
https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/1208c2cd-0401-0010-4ab6-f4736074acc6
Don't go by the title of the document, in this tutorial, they explain how to convert an XML string to XML format and thus open it using an Excel application.
Regards,
Subramanian V.
Hi Mahesh,
Clean your xml using followin code i.e remove all empty nodes. These empty nodes may have name as null or "#text".
try
{
Document doc = builder.parse(inputstrm);
Element root = doc.getDocumentElement();
NodeList ndLst = root.getChildNodes();
for(int i=0;i<ndLst.getLength();i++)
{
Node tmp = ndLst.item(i);
if(tmp.getNodeName().compareToIgnoreCase("") == 0 || tmp.getNodeName().compareToIgnoreCase("#text") == 0)
{
root.removeChild(tmp);
}
}
}
catch(Exception e)
{}
Hope this solves your problem
Regards,
Mayank
Add a comment