Invalide encoding name
843834Aug 29 2008 — edited Sep 10 2008I have big issue regarding parsing xml file using "unicode" encoding.
I will be very thankful to solve this problem,because i have checked too much things to
solve but the problem of uncode encoding occurs:
Exception error display is
org.xml.sax.SAXParseException: Invalid encoding name "Unicode"
where my xml file is some how like this:
<?xml version="1.0" encoding="UTF-8" ?>
<CARData>
<DataRow>
<Permittee_ID>00180</Permittee_ID>
</DataRow>
</CARData>
and piece of code used for parsing is
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse (new File(fileName));
doc.getDocumentElement ().normalize ();
NodeList listOfRows = doc.getElementsByTagName("DataRow");
int totalRows = listOfRows.getLength();
System.out.println("Total no of Rows : " + totalRows);
if(totalRows>0)
{
for(int s=0; s<listOfRows.getLength() ; s++){
xd=new XML_File_Detail();
Node firstNode = listOfRows.item(s);
if(firstNode.getNodeType() == Node.ELEMENT_NODE){
Element firstPersonElement = (Element)firstNode;
//-------
NodeList pidList = firstPersonElement.getElementsByTagName("Permittee_ID");
Element pidElement = (Element)pidList.item(0);
NodeList textpidList = pidElement.getChildNodes();
if((Node)textpidList.item(0)!=null)
permiteeId=((Node)textpidList.item(0)).getNodeValue().trim();
else
permiteeId="";
xd.setPermitteeID(permiteeId);
}