View Single Post
  #10 (permalink)  
Old 07-03-2008, 11:30 AM
coolnfunky_raj coolnfunky_raj is offline
Member
 
Join Date: Jul 2008
Posts: 6
coolnfunky_raj is on a distinguished road
Ok. I am actually writing a plugin for a tool I am using at work. The plugin should parse an XML input file and return a 2D string array. The tool provides a class called Plugin, and I am extending this class to add my implementation.

I am using SAX Parser and the startElement() is triggered whenever a new tag is parsed in the XML File. I am adding the name of the tag to an ArrayList (arr). Whenever closing tag is encountered, endElement() is triggered by the parser. I am deleting the last added tag name in the ArrayList (arr). By doing this, I keep track of the path of the current tag from root tag in the input XML file. Also in the endElement() method, I am adding the current path stored in arr to arrOfArr. Hence, in the end, arrOfArr will have an array of the paths of each node from root node.
Reply With Quote