• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

A question on SAXParser

 
Ranch Hand
Posts: 463
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone ,
I have a simple XML which I need to pull a node out data-assoc.
<esrv><data><query><data-assoc><table>TableName</table><view><col>a</col><col>b</col></view><data-assoc><query><data><esrv>
data-assoc .
This is really a big XML which has lot of values in attributes and lots more tags which I have omitted and has already been implemented by previous programmer in SAXParser so I dont want to break this code by introducing DOM Parser which would solve this problem very easily.
I also dont want to mix a DOM and a SAXParser so I have to do this with a SAXParser for now.
Can some one tell me the fastest way to get that node using SAXParser(data-assoc) or do I need to read each tag step by step and keep on appending to the value to finally give the entire tree under data-assoc .
Thanks every one
Dhiren
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm afraid the "best" solution depends on how the existing code is implemented (and I know SAX handlers can get very ugly...).
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im not real clear on what you mean by pulling out the node.
Generally your SAX processing code would watch for the node of interest in the startElement method - when the one you want comes along, set some sort of flag and start processing all events until the matching endElement method is called.
What do you want to do to the data-assoc node?
Bill
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic