char *gf_dom_flatten_textContent(GF_Node *n)
{
	u32 len = 0;
	char *res = NULL;
	GF_ChildNodeItem *list;
	if (!n) return NULL;

	if ((n->sgprivate->tag==TAG_DOMText) && ((GF_DOMText*)n)->textContent) {
		/*if ( ((GF_DOMText*)n)->type == GF_DOM_TEXT_REGULAR) */{
			res = gf_strdup(((GF_DOMText*)n)->textContent);
			len = (u32) strlen(res);
		}
	}

	list = ((GF_ParentNode *)n)->children;
	while (list) {
		char *t = gf_dom_flatten_textContent(list->node);
		if (t) {
			size_t sub_len = strlen(t);
			res = (char *)gf_realloc(res, sizeof(char)*(len+sub_len+1));
			if (!len) res[0] = 0;
			len += (u32)sub_len;
			strcat(res, t);
			gf_free(t);
		}
		list = list->next;
	}
	return res;
}
char *gf_dom_flatten_textContent(GF_Node *n)
{
	u32 len = 0;
	char *res = NULL;
	GF_ChildNodeItem *list;
	if (!n) return NULL;

	if ((n->sgprivate->tag==TAG_DOMText) && ((GF_DOMText*)n)->textContent) {
		 {
			res = gf_strdup(((GF_DOMText*)n)->textContent);
			len = (u32) strlen(res);
		}
	}

	list = ((GF_ParentNode *)n)->children;
	while (list) {
		char *t = gf_dom_flatten_textContent(list->node);
		if (t) {
			size_t sub_len = strlen(t);
			res = (char *)gf_realloc(res, sizeof(char)*(len+sub_len+1));
			if (!len) res[0] = 0;
			len += (u32)sub_len;
			strcat(res, t);
			gf_free(t);
		}
		list = list->next;
	}
	return res;
}