public void writeEndElement()
    {
        try
        {
            level--;
            if (lastElement == Elements.OPEN_TAG || lastElement == Elements.ATTRIBUTE)
            {
                xmlWriter.write(" />");
                elementStack.pop();
            }
            else
            {
                if (lastElement != Elements.STRING)
                {
                    xmlWriter.write("\n");
                    indent();
                }
                
                xmlWriter.write("</" + elementStack.pop() + ">");
            }
            lastElement = Elements.CLOSED_TAG;
        }
        catch (IOException ex)
        {
            ex.printStackTrace();
        }
    }