Put it back in res/xml/. Use getResources().getXml() to get an XmlPullParser on the file.
On Thu, Jul 1, 2010 at 2:47 PM, RespeckKnuckles (John Licato) <respeckknuckl...@gmail.com> wrote: > Just in case the <?xml ?> element was the problem, I tried this xml > code instead: > > <?xml version="1.0" encoding="utf-8"?> > <HTML></HTML> > > and still didn't work. > > On Jul 1, 12:46 pm, "RespeckKnuckles (John Licato)" > <respeckknuckl...@gmail.com> wrote: >> Hey guys, >> >> I put the xml file into the res/raw directory and it works better, but >> still not working completely. Here is the code I'm using: >> >> InputStream toParse = >> getResources().openRawResource(R.raw.test); // >> file is in res/raw/test.xml >> DocumentBuilder db = >> >> DocumentBuilderFactory.newInstance().newDocumentBuilder(); >> Document d = db.parse(toParse); >> Element rootElement = d.getDocumentElement(); >> >> It fails at db.parse(), saying "Unexpected end of document found." >> I've converted the toParse stream into a string and verified it is >> correct, and I simplified it so that the only xml it reads is: >> >> <HTML></HTML> >> >> and it still says the same thing. This may be more of a java DOM >> issue, but do any of you have any ideas? >> >> On Jul 1, 1:42 am, piyu <spk2p...@gmail.com> wrote: >> >> >> >> > Hi John, >> >> > Can copy here code to know how you are reading fron input stream. >> >> > Thanks in advance. >> >> > On Jul 1, 12:36 am, "RespeckKnuckles(John Licato)" >> >> > <respeckknuckl...@gmail.com> wrote: >> > > Hey guys, >> >> > > I have some xml files with a custom format (based on the scxml >> > > specifications) that I want my program to read. I've already written >> > > the code to read it, but I'm running into problems actually reading >> > > the file itself. I want the file to be compiled with the apk, as it >> > > will not be changed at all during run time. So I put the file >> > > (test.xml) in the res/xml/ folder, and got the inputstream by using: >> >> > > getResources().openRawResource(R.xml.test); >> >> > > but when I read in this inputstream it is complete jibberish, which >> > > makes me suspect it is being read in binary, as openRawResource() is >> > > often used for binary files like images, if I am correct. What is the >> > > correct way to do this? > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en