• 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
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Xml Parsing

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Java Lovers

I have just started SAX Parsing in Java.



Now I wanna parse the particular group(like admin,contact etc) and get the passcount of that particulatr group only .For example if I a want admin details

I shoud get the following output


Please help me with it.
 
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
What do you have so far? Can you detect when a <Date> Element occurs?

Bill
 
vineet kumar chaudhry
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was using below code



It gives me the following output

admin
Date :--->

Passcount :--->

admin
Date :--->

Passcount :--->
 
William Brogden
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
Try not setting bfname or the other flags to false until the matching endElement() is called.

Note that the characters () method may be called multiple times inside a given Text node.

Bill
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is how it should be modified (overlapping what have been advised).

[1] If you want to use String s uniformly and generally in the handler, move the declaration outside of the startElement handling.

[2] In the same spirit of electing the flags in the startElement() because the detection in all cases of interested is on the element's name, you should take down the flags in the endElement().

[3] Flags shouldn't be switched in the characters handling.
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic