MinXML Cheatsheet

This is a quick reference for using the com.steelypip.powerups.minxml package from steelypip.com.

Work in Progress

Package Structure

  • All the classes you need come from a single package: com.steelypip.powerups.minxml.


  • To parse MinXML text, create a MinXML parser with new MinXMLParser( java.io.Reader r ).

The MinXML interface

  • MinXML is an interface, so you create new instances using specialised constructors. There are getters and setters for the name, attributes and children. However a class may optionally decline to implement any of the setters and trying to use a disallowed setter will throw an UnsupportedOperationException.
  • An all-round useful implementation of MinXML is provided, called FlexiMinXML. It is equipped with a public constructor new FlexiMinXML( String element_name ) and supports all setters.

Element Names

  • Use MinXML#getName() and MinXML#setName(String) to access and update the name of an MinXML element.


  • MinXML objects inherit from List< MinXML > and the where the members of the list are the child elements.
  • Use List operations, such as get, set, add, iterator etc, to access and manage the children of an element.


  • Get or set attributes using MinXML#getAttribute( String key ) and MinXML#putAttribute( String key, String value ). If the attribute is missing, getAttribute will return null. If you want to control the value that is returned when the key is missing, use MinXML#getAttribute( String key, String value_otherwise ).
  • Check if an attribute is present using MinXML#hasAttribute( String key ) and whether it has a specific value with MinXML#hasAttribute( String key, String expected_value).
  • Get all the attributes as a map that shares the underlying store with MinXML#asMap() and the key-set with MinXML#asMapKeys().
  • If you want a copy of the attributes that does not shares its underlying store, use MinXML#getAttributes() and a copy of the key-set with MinXML#keys. By not sharing the underlying sore, it makes it safer to iterate over the copy whilst updating the elements of the original.


  • Write a MinXML element e to java.io.PrintWriter pw e.print(pw). Pretty print is e.prettyPrint(pw)

Recursive Processes

  • Recursively process all the elements of a tree using MinXMLWalker.
  • Recursively search-for or simply process selected elements of a tree using MinXMLSearcher.
  • Convert a recursive process into a pre-order or post-order traversal using MinXMLWalker#preOrder(MinXML subject) and MinXMLWalker#postOrder(MinXML subject)
  • If the recursive is more selective, convert to an iterative traversal using MinXMLSearcher#preOrder(MinXML subject) or MinXMLSearcher#postOrder(MinXML subject).