Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

SAX and characters() -method

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Still quite new to SAX-parsing and would appreciate any help on this matter.

Ok, I have the characters-method to capture the elements I need but have problem when trying to save them to an dynamic array for later use.



If I try to save them to an array in the above if-clause, it just shows null when I'm trying to read the array somewhere outside characters()-method. At the moment I've come around this by writing the results to a .txt-file (yeah, how stupid) and retrieving the results from there when needed.



Above is the method where the actual parsing is invoked.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

If I try to save them to an array in the above if-clause,


If by that you mean you are trying to save the char[] reference, thats the wrong approach. That char[] is the buffer the SAX parser is using!
A typical approach is to use a StringBuffer and the append( char[], int offset, int len ) method.
Create the StringBuffer when the startElement for the element you want occurs. Recall that the SAX parser may call characters one or many times before the end of the element is reached.
Bill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic