func (tag *Tag) CountSiblings() int {
	sib := tag.nextSibling
	if sib == nil {
		return 0
	}
	count := 1
	if sib.nextSibling == nil {
		return count
	}
	sib = sib.nextSibling
	for sib != nil {
		count++
		sib = sib.nextSibling
	}
	return count
}
CountSiblings returns the number of siblings a tag has
package tinysvg
import (
	"bytes"
	"fmt"
	"io/ioutil"
)
type Tag struct {
	name        []byte
	content     []byte
	lastContent []byte
	xmlContent  []byte
	attrs       map[string][]byte
	nextSibling *Tag  
	firstChild  *Tag  
}
type Document struct {
	title []byte
	root  *Tag
}
func NewDocument(title, rootTagName []byte) *Document {
	var image Document
	image.title = []byte(title)
	rootTag := NewTag([]byte(rootTagName))
	image.root = rootTag
	return &image
}
func NewTag(name []byte) *Tag {
	var tag Tag
	tag.name = name
	tag.attrs = make(map[string][]byte)
	tag.nextSibling = nil
	tag.firstChild = nil
	tag.content = make([]byte, 0)
	tag.lastContent = make([]byte, 0)
	return &tag
}
func (tag *Tag) AddNewTag(name []byte) *Tag {
	child := NewTag(name)
	tag.AddChild(child)
	return child
}
func (tag *Tag) AddTag(child *Tag) {
	tag.AddChild(child)
}
func (tag *Tag) AddAttrib(attrName string, attrValue []byte) {
	tag.attrs[attrName] = attrValue
}
func (tag *Tag) AddSingularAttrib(attrName string) {
	tag.attrs[attrName] = nil
}
func (tag *Tag) GetAttrString() []byte {
	ret := make([]byte, 0)
	for key, value := range tag.attrs {
		if value == nil {
			ret = append(ret, key...)
			ret = append(ret, ' ')
		} else {
			ret = append(ret, key...)
			ret = append(ret, []byte("=\"")...)
			ret = append(ret, value...)
			ret = append(ret, []byte("\" ")...)
		}
	}
	if len(ret) > 0 {
		ret = ret[:len(ret)-1]
	}
	return ret
}
func getSpaces(level int) []byte {
	spacing := make([]byte, 0)
	for i := 1; i < level; i++ {
		spacing = append(spacing, []byte("  ")...)
	}
	return spacing
}
func (tag *Tag) getFlatXML() []byte {
	if (len(tag.name) > 0) && (tag.name[0] == '<') {
		ret := make([]byte, 0, len(tag.name)+len(tag.content)+len(tag.xmlContent)+len(tag.lastContent))
		ret = append(ret, tag.name...)
		ret = append(ret, tag.content...)
		ret = append(ret, tag.xmlContent...)
		ret = append(ret, tag.lastContent...)
		return ret
	}
	spacing := make([]byte, 0)
	attrs := tag.GetAttrString()
	ret := make([]byte, 0)
	ret = append(ret, spacing...)
	ret = append(ret, []byte("<")...)
	ret = append(ret, tag.name...)
	if len(attrs) > 0 {
		ret = append(ret, []byte(" ")...)
		ret = append(ret, attrs...)
	}
	if (len(tag.content) == 0) && (len(tag.xmlContent) == 0) && (len(tag.lastContent) == 0) {
		ret = append(ret, []byte(" />")...)
	} else {
		if len(tag.xmlContent) > 0 {
			if tag.xmlContent[0] != ' ' {
				ret = append(ret, []byte(">")...)
				ret = append(ret, spacing...)
				ret = append(ret, tag.xmlContent...)
				ret = append(ret, spacing...)
				ret = append(ret, []byte("</")...)
				ret = append(ret, tag.name...)
				ret = append(ret, []byte(">")...)
			} else {
				ret = append(ret, []byte(">")...)
				ret = append(ret, tag.xmlContent...)
				ret = append(ret, spacing...)
				ret = append(ret, []byte("</")...)
				ret = append(ret, tag.name...)
				ret = append(ret, []byte(">")...)
			}
		} else {
			ret = append(ret, []byte(">")...)
			ret = append(ret, tag.content...)
			ret = append(ret, tag.lastContent...)
			ret = append(ret, []byte("</")...)
			ret = append(ret, tag.name...)
			ret = append(ret, []byte(">")...)
		}
	}
	return ret
}
func (tag *Tag) GetChildren() []*Tag {
	var children []*Tag
	current := tag.firstChild
	for current != nil {
		children = append(children, current)
		current = current.nextSibling
	}
	return children
}
func (tag *Tag) AddChild(child *Tag) {
	if tag.firstChild == nil {
		tag.firstChild = child
		return
	}
	lastChild := tag.LastChild()
	child.nextSibling = nil
	lastChild.nextSibling = child
}
func (tag *Tag) AddContent(content []byte) {
	tag.content = append(tag.content, content...)
}
func (tag *Tag) AppendContent(content []byte) {
	tag.lastContent = append(tag.lastContent, content...)
}
func (tag *Tag) AddLastContent(content []byte) {
	tag.AppendContent(content)
}
func (tag *Tag) CountChildren() int {
	child := tag.firstChild
	if child == nil {
		return 0
	}
	count := 1
	if child.nextSibling == nil {
		return count
	}
	child = child.nextSibling
	for child != nil {
		count++
		child = child.nextSibling
	}
	return count
}