I think it's better DOM than SAX in your case, why?, you had it on a String, so it is in memory (the information), DOM read everything and put it in memory, so, you can put in memory and then "free" the String memory.
To do it is so easy: 1- Create a StringBufferInputStream with your String 2- Create a DocumentBuilder (with the DocumentBuilderFactory class) 3- Parse your StringBufferInputStream with your DocumentBuilder Luck!!! On 18 dic, 19:50, redders <redders6...@googlemail.com> wrote: > Okay, so I know that the parse() method takes an inputsource, and > normally it'd be better to parse the xml at the source (where it's a > stream), but in this case I want to be parsing it on a different > thread to the thread it's being received on. > > My question is basically a "why won't this work" question... > As far as I can tell, the startElement method is never being called > (no "startelement" entries in logcat after "trying to parse..") > .. any help appreciated. > > Here's the code. > > public class NWCommsXMLParser extends DefaultHandler{ > public void startElement(String uri, String name, String qName, > Attributes atts){ > Log.i("NWXML","startelement: " + uri + "." + name + "." + > qName + > "/" + atts.toString()); > } > public void endElement(String uri, String name, String qName){ > > } > public void characters(char ch[], int start, int length) { > > } > public void parseMessage(String xmlMessage){ > > Log.i("NWXML","Trying to parse: " + xmlMessage); > try{ > SAXParserFactory parseFactory = > SAXParserFactory.newInstance(); > SAXParser parser = parseFactory.newSAXParser(); > XMLReader xmlReader = parser.getXMLReader(); > xmlReader.setContentHandler(this); > StringReader sr = new StringReader(xmlMessage); > InputSource is = new InputSource(sr); > xmlReader.parse(is); > } > catch(Exception e){ > Log.e("NanoWarsXML","SAX error:" + e); > } > } > > } > > Logcat line before the try{} : > 12-19 01:31:38.763: INFO/NWXML(3218): > Trying to parse: > <NWC><NWR type="dat" id="1" ><PSL>123447</PSL><PSLg>87645</PSLg></ > NWR></NWC> -- 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