AssetFX
asked on
Parsing FileInputStream for xml on Android
Hi,
I am running Android 4.0 API Level 14
This is my xml file
I thought it might be something to do with the UTF-8 encoding.
Any help would be greatly appreciated!
I am running Android 4.0 API Level 14
This is my xml file
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<local_root />
This is my javaDocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
fileRead = new FileInputStream(localXMLfile);
Document doc = db.parse(fileRead);
doc.getDocumentElement().normalize();
NodeList nodeList = doc.getElementsByTagName("local_root");
It is throwing the following exceptionorg.xml.sax.SAXParseExcepton this line:ion: Unexpected token (position:TEXT ?xml version='1....@2:1 in java.io.InputStreamReader@ 413b7ab8)
Document doc = db.parse(fileRead);
I thought it might be something to do with the UTF-8 encoding.
Any help would be greatly appreciated!
Make sure there's no BOM at the beginning of the file. Save the file in a simple text editor and it shouldn't get one
ASKER
Hi,
this xml is created dynamically so saving each time in a text editor doesn't really cut it.
However just added in a check to see if it had BOM and it does not. The check comes from http://stackoverflow.com/q uestions/1 835430/byt e-order-ma rk-screws- up-file-re ading-in-j ava
this xml is created dynamically so saving each time in a text editor doesn't really cut it.
However just added in a check to see if it had BOM and it does not. The check comes from http://stackoverflow.com/q
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
See if you can attach one here without altering it in any way