private String getPrettyElement(Element element, int level){
        String prettyXml = "";

        if(level > 0){
            //add indention
            prettyXml += this.lineSeperator + getIndenting(level);
        }

        //add initial tag
        if(encodeXml){
            prettyXml += XmlEncoder.encode(element.getStartTag().toString());
        }else{
            prettyXml += element.getStartTag().toString();
        }

        if(!element.getStartTag().isSelfClosing()){
            if(!element.getText().equals("")){
//                if(element.hasChildren()){
//                    prettyXml += this.lineSeperator + getIndenting(level);
//                }
                prettyXml += element.getText().toString();
            }

            for(Element child : element.getChildren()){
                prettyXml += getPrettyElement(child, level + 1);
            }

            if(element.hasChildren()){
                prettyXml += this.lineSeperator + getIndenting(level);
            }

            if(encodeXml){
                prettyXml += XmlEncoder.encode(element.getEndTag().toString());
            }else {
                prettyXml += element.getEndTag().toString();
            }
        }

        return prettyXml;
    }