• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

retrieving data from SAX parser

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
does anyone know how to actually get the data that has been parsed from a SAX parser....
i understand that you override the endDocument, endElement, etc methods, but if i want to store data parsed by those methods into an array and pass the array to another class - how can i do that??
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you override 'startElement', you can get at the names of the elements and the attributes through the method parameters. If you override 'characters', you get the text between tags through its parameters. Is that what you are looking for? If not, then describe in more detail where you're stuck.
 
Michael Lipton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no, i have that part... but it seems that those methods are great if you can handle the data inside the StartElement methods (or other overloaded method)
what i would like to do is have an array that holds the data of some elements... once the parser is done, i want to send that array to another class for processing, but i cant find a nice way to do this
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Keep a List (e.g. "List elements = new ArrayList()") outside of the SAX methods. Then in startElement you can call "elements.add(localName)", thus remembering the succession of elements in the document. After endDocument is called you can then use that List in whatever way you need to.
 
God is a comedian playing for an audience that is afraid to laugh - Voltair. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic