private Tag getTag(){
        String value = "";
        String name = "";
        int charCode;
        Tag tag;
        boolean isClosingTag = false;
        boolean isSelfClosingTag = false;
        boolean done = false;
        List<Attribute> attributes = new ArrayList<Attribute>();
        Attribute attribute;

        //consume the less than sign
        value += this.xmlChars[index];
        this.index++;

        while(!done){

            charCode = this.xmlChars[index];

            if(isWhiteSpace(charCode)){
                value += (char) charCode;
                this.index++;
                continue;
            }

            if(charCode == ASCII_CHAR_VALUE_FORWARD_SLASH){
                value += (char) charCode;
                this.index++;
                if(name.equals("")){
                    isClosingTag = true;
                }else{
                    isSelfClosingTag = true;
                }
            }else{
                if(name.equals("")){
                    name = getElementName();
                    value += name;
                }else{
                    attribute = getAttribute();
                    value += attribute.getText();
                    attributes.add(attribute);
                }
            }

            //get the current char to test
            charCode = this.xmlChars[index];

            if(charCode == ASCII_CHAR_VALUE_GREATER_THAN){
                done = true;
                value += (char) charCode;
                this.index++;
            }
        }

        tag = new Tag(name, value, attributes, isClosingTag, isSelfClosingTag);

        return tag;
    }