# SaxBuilder

version 3.0.23

A builder for generating Simple API for XML (SAX) events.

If you have the following SAX handler:

    class LogHandler extends org.xml.sax.helpers.DefaultHandler {

        String log = ''

        void startElement(String uri, String localName, String qName, org.xml.sax.Attributes attributes) {
            log += "Start Element: $localName, "
        }

        void endElement(String uri, String localName, String qName) {
            log += "End Element: $localName, "
        }
    }

You can use `SaxBuilder` to generate SAX events for the handler like this:

    def handler = new LogHandler()
    def builder = new groovy.xml.SAXBuilder(handler)

    builder.root() {
        helloWorld()
    }

And then check that everything worked as expected:

    assert handler.log == 'Start Element: root, Start Element: helloWorld, End Element: helloWorld, End Element: root, '