I was happy to have my first opportunity at delivering an open-source project for the use of everyone. This project is available here and has been uploaded into Sonatype’s Central Maven Repository.
Isn’t there already XML Parsers for Java?
It may seem weird as there are already many XML parser out there for Java. Actually I was using XML in an odd scenario and could not find a solution suitable to my needs after a few hours of searching.
I noticed that many libraries that were available were verbose and I wanted to minimize the number of lines required to load the XML file content. I also needed it to be able to accommodate XML that is not intended to represent structured data (objects with the same attributes) but rather I needed it to be able to handle the unstructured data that can be found in an application configuration file.
Oddly, after completing the library I did read about a Java Library called XPath and also read that the same solution was not geared toward performance consideration.
Why not write a Java properties file?
One of the considerations I had is if I needed to move the config in the future I would rather have it as an XML as parsers would be available for many programming languages.
Another is that the properties file can become really difficult to read and maintain if your intention is to logically nest objects within others. Imagine having to read keys like:
Now try nesting a few more times to see the point.
What is it about?
The project basically is geared towards reading an entire XML file and providing it as key->value pairs in a HashMap. In order to accomplish this, a few assumptions had to be made in order for the library to work effectively.
The readme in GitHub explains what these assumptions are as well as the rules used for generating the keys for each value.