Implemented selector support for XML formatter.
Refactored selector support and made it more DRY. Tweaked JSON parser to only add instance name when appropriate.