I recently worked on a project in which the source data was KML, the XML file format used by Google Maps. In this project I wanted to create an interactive map of the US without needing to rely on Google Maps or an expensive third-party library. I had a specific set of features I needed and having dealt with KML files before on another mapping project, I wasn’t scared of trying to do it in all HTML/JS.
My first approach resulted in my stumbling across a web page at Mozilla’s developer website about Parsing and Serializing XML. It talked about JXON (I pronounce as jackson):
I found this very interesting and started to read through the different implementations. Some I generally like, others not so much.
After playing around with the concept, I created a library for the project to parse XML into JSON objects. It worked rather well and could handle native XML DOM Elements, XML Strings, and remove XML Files.
A mascot already?
[This is a personal note so skip it if you don't really care.]
It was ironic, in a personal way, that I was writing all this code at home while my dog was laying by my bed. You ask why? My dog, a large Golden Retriever, is named Jackson. As I was trying to explain to my wife what I was doing instead of sleeping, I told her I working on something called “jackson” and she asked, “What’s that have to do with him?”. After a moment of confusion, it realized the irony and told my wife, “He’s the mascot for this code I’m writing.”. Here’s a picture of Jackson many years ago, my mascot for JXON.
JXON gets loose!
In the end, I scrapped that library because it was too generic for what I wanted and replaced it with a KML specific one. However, I wanted to share the wealth and provide it to everyone if they so cared to look at it. It is now available on GitHub at: https://github.com/DMGambone/JXON-Parser.
Feel free to pull it, expand it, make it so much cooler than I ever could!
JXON has a lot left in order to grow
There is some features I do want to add that I didn’t bother with when I was working on this. The biggest one was adding a ‘query’ method to the JXONNode object. The goal was to accept an XPath like string and then return an array of matching JXONNode objects. Some day I’ll site down and do it.