troubleshooting Question

Parsing FileInputStream for xml on Android

Avatar of AssetFX
AssetFXFlag for Australia asked on
4 Comments1 Solution3355 ViewsLast Modified:
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 java
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
fileRead = new FileInputStream(localXMLfile);
Document doc = db.parse(fileRead);

NodeList nodeList = doc.getElementsByTagName("local_root");
It is throwing the following exception
org.xml.sax.SAXParseException: Unexpected token (position:TEXT ?xml version='1....@2:1 in
on this line:
Document doc = db.parse(fileRead);

I thought it might be something to do with the UTF-8 encoding.

Any help would be greatly appreciated!
Sharon Seth
Software Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros