This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

How to know if a parsed character using SAX parser is a new line character ?  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using SAX parser to parse an XML file which has <pre> element. Now I want to display the content in this tag as it is ( which includes tabs and carriage returns) into a jsp file. But I think that the parser is not recognizing carriage returns.
eg.
<pre>NameAgeSexRoks22MaleAman44Male</pre>

The output should be:
Name Age Sex
Roks 22 Male
Aman 44 Male

I think that in the characters() method the nextline characters after Sex,Male are not read. The encoding used is iso-8859-1.

The output which I am getting is :

Name Age Sex Roks 22 Male Aman 44 Male
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The characters() method will be getting exactly the characters in the element, but note that you can't be sure that one call has the complete text. Due to the fact that SAX parsers read one buffer at a time and do NOT assemble the characters for you. There may be a second call to characters() containing the data that was truncated.
It is more likely that the HTML browser is discarding extra spaces tabs and cr for some reason.
Bill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!