Sax Class Generator -v1.0


Sax Class Generator is a class used to create a java class that extends org.xml.sax.helpers.DefaultHandler.

It creates everything based on the tree structure of the xml that you provide.

Current version depends on the GUI interface to get the nodes(structure) of the xml.





How to use:

1- Once launched, You will be looking at the nodes in the top level of the expected xml file.

2- Add as much root nodes as you need.

3- For any node with children, Browse it and add nodes inside.

4- Do step 3 for all nodes with children.

5- Finally export the structure -e.g. Create the java class.

Enjoy it! I think it saves lots of times and spans your whole xml structure.

I hope that you all know how to use the class. In case you don't.


String yourXmlString;
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();

/* Create a new instance of the class generated */
GeneratedHandler handler = new GeneratedHandler ();
xr.setContentHandler(handler);

InputSource inputSource = new InputSource();
inputSource.setEncoding("UTF-8");
inputSource.setCharacterStream(new StringReader(response));

/* Start Parsing */
xr.parse(inputSource);
/* Parsing Done. */

Your job is to fill in the blanks in the class created so that you can instantiate objects of your own or Arrays or any sort of data that the xml contains.

Click here for Sample Project (download)

1 comment:

  1. Uncharted 5 will be unbelievable if Cassie came in as Nate's replacement! As the daughter of Elena and Nathan, she has all the resources she will ever need to become the next treasure hunter in the family. And having her as the protagonist will ensure that we get to see Nate, Elena, and everyone else in at least some capacity. Uncharted 5 Official Trailer

    ReplyDelete