• 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

SAX praser passing element's attribute value dynamically

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
i have very poor knowledge in XML .

Am using SAX parser to parse a xml file.

my question is by passing element's attribute value dynamically can i get element details and list of elements.

for example



by passing employee type can i get the list of users i.e user details using SAX parser.if so how to do please provide with sample code.

thanks,
Shabarish.V
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you mean that -given one of "permanent" or "contract"- you want the parser to ignore all employees of the other type?

If so, you could set a boolean "ignore" to false/true in the startElement method of the DocumentHandler, depending on the value of the "type" attribute. All other code in the DocumentHandler can then skip processing if "ignore" is set to true.

Alternatively, you could write an XPath expression that returns only employees of a suitable type. Then you'd be working with DOM, not SAX, though.
 
shabarish vai
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Ulf Dittmer for the reply,
yes your correct either if i pass permanent or contract i should get that particular employee details
 
shabarish vai
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how i do i do with xpath any example
 
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
A good starting point on how to perform XPath processing in Java is this article: http://www.ibm.com/developerworks/library/x-javaxpathapi.html

The XPath standard is also helpful reading.
 
Then YOU must do the pig's work! Read this tiny ad. READ IT!
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic