The characters() method may be called several times, so you need to use a StringBuilder to append all the information. See the following links: http://stackoverflow.com/questions/2838099/android-sax-parser-not-getting-full-text-from-between-tags http://www.ibm.com/developerworks/opensource/library/x-android
On 11 Aug, 09:10, Prashant Mahajan <[email protected]> wrote: > Hello Everyone, > > I am using Saxparser and also giving name of the tags in startElement and > endElement methods. But i am not getting whole text in between two tags.m > only getting half of the text. Also if der is a space between two sentences > of the text data in xml, i am getting the text after the space in output but > not the complete text. How to overcome this flaw...? Kindly Help.. Thanks in > advance. > > *The text data in xml is in the format shown below.* > <Desc><![CDATA[ > > Contrary to popular belief, Lorem Ipsum is not simply random text. It has > roots in a piece of classical Latin literature from 45 BC, making it over > 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney > College in Virginia, looked up one of the more obscure Latin words, > consectetur, from a Lorem Ipsum passage, and going through the cites of the > word in classical literature, discovered the undoubtable source. Lorem Ipsum > comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" > (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a > treatise on the theory of ethics, very popular during the Renaissance. The > first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line > in section 1.10.32. > > "The standard chunk of Lorem Ipsum used since the 1500s is reproduced below > for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum > et Malorum" by Cicero are also reproduced in their exact original form, > accompanied by English versions from the 1914 translation by H. Rackham."] > ]></Desc> > > *And part of MyCode is as follows;* > > public byte parse() { > SAXParserFactory spf = null; > SAXParser sp = null; > InputStream inputStream = null; > > try { > inputStream = new ByteArrayInputStream(data.getBytes()); > spf = SAXParserFactory.newInstance(); > if (spf != null) { > sp = spf.newSAXParser(); > sp.parse(inputStream, this); > } > } > > catch (Exception e) { > System.out.println("Exception: " + e); > e.printStackTrace(); > } finally { > try { > if (inputStream != null) > inputStream.close(); > } catch (Exception e) { > } > } > > } > > public void startElement(String uri, String localName, String qName, > Attributes attributes) throws SAXException { > > tempVal = ""; > > if (localName.equals("Desc")) { > track = new Track(); > isABC = true; > } > > } > > public void characters(char[] ch, int start, int length) > throws SAXException { > tempVal = new String(ch, start, length); > } > > public void endElement(String uri, String localName, String qName) > throws SAXException { > > if (localName.equals("Desc")) > { > // add it to the list > abclist.addElement((track)); > isABC = false; > } > > > > > > > > } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

