I have functionality which reads XML file, gets data from the nodes and take an appropriate action to execute the business logic. I am using the below code:
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(fileName);
XML file I am getting as an input is modified by the end user. He adds the data into it and then using my functionality that data is getting into system. In this scenario I am getting an JDOM parser exception "Document root element is missing.."
Reason is the editor used to modify XML appends some charachters at the begining of file and it fails in reading this.
Is there any way I can handle this problem? Either removing this chars or ignoring them. These chars are not predicatable, those might be some garbage values also.