private Element getRootElement(XmlTokenizer tokenizer) throws XmlException{
        Element root = new Element();
        Element child;
        Token token;
        Tag tag;
        boolean hasOpenningTag = false;

        while(tokenizer.hasNextToken()){
            token = tokenizer.getNextToken();

            if(token instanceof Tag){
                tag = (Tag) token;
                if(!hasOpenningTag){

                    if(tag.isClosingTag()){
                        throw new XmlException("Closing tag before opening tag");
                    }

                    root.setStartTag(tag);
                    hasOpenningTag = true;
                }else{

                    if(tag.isClosingTag()){
                        root.setEndTag(tag);
                    }else{
                        child = getChildElement(tokenizer, tag);
                        root.addChildElement(child);
                    }
                }
            }else if(token instanceof Text){
                root.setText((Text) token);
            }
        }

        return root;
    }