aspose file tools
The moose likes XML and Related Technologies and the fly likes SAX praser passing element's attribute value dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "SAX praser passing element Watch "SAX praser passing element New topic
Author

SAX praser passing element's attribute value dynamically

shabarish vai
Ranch Hand

Joined: May 26, 2008
Posts: 79
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
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35241
    
    7
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.


Android appsImageJ pluginsJava web charts
shabarish vai
Ranch Hand

Joined: May 26, 2008
Posts: 79
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

Joined: May 26, 2008
Posts: 79
how i do i do with xpath any example
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35241
    
    7
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SAX praser passing element's attribute value dynamically
 
Similar Threads
Capturing a list of details from the UI to ActionForm
how to construct attribute list
problem javascript
Let's discuss the sample test
Right Answer