Android XML parse failed Unexpected token

ThitsstispCom

New Member
In my app(game), i need to read a XML script and turn in into a class object; i've completed the entire XML reader via DOM but when i run , i got the following error:\[code\]05-08 23:03:22.342: I/System.out(588): XML Pasing Excpetion = org.xml.sax.SAXParseException: Unexpected token (position:TEXT ????????????????????...@1:69 in java.io.InputStreamReader@4129a200) \[/code\]i've read some answers about this but they all failed to fix my problem (http://stackoverflow.com/questions/7885962/android-utf-8-file-parsing)..here's my code:\[code\] InputStream inputStream = ctx.getResources().openRawResource(R.xml.script);ctx.getApplicationContext().getPackageName()+"/xml/"+path); Reader reader = new InputStreamReader(inputStream,"UTF-8"); InputSource is = new InputSource(reader); is.setEncoding("UTF-8"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document root = db.parse(is);\[/code\]according to the problem, i've also tried this to:\[code\] InputStream inputStream = ctx.getResources().openRawResource(R.xml.script); Document root = db.parse(inputStream);\[/code\]which produced exactly the same exceptions...how to solve this problem?my xml file:\[code\]<script><scene no="0"> <character id="1">1</character> <dialog no="1"> <title>1</title> Sub-Element 1 </dialog></scene></script>\[/code\]
 
Back
Top