GString*
xml_tree_dump_node_indent (GString* g, xml_GNode* node, gsize nl, int indent)
{
if (! g) g = g_string_new(0);
if (node->name)
{
switch (node->name[0])
{
case '<':
g = g_string_append (g, node->name);
break;
default:
g = g_string_append_c (g, '<');
g = g_string_append (g, node->name);
xml_attr_list_string_append (g, node->attributes);
g = g_string_append_c (g, '>');
break;
} |
if (node->text)
g_string_append_printf (g, "%i/%i", node->off, node->end);
} |
if (nl < g->len)
{
g_string_append_newline_indent (g, indent);
xml_tree_dump_node_links (g, node);
} |
if (node->children)
{
xml_GNode* child = node->children;
for (; child ; child = child->next)
{
if (nl < g->len) nl = g->len + 1;
g = g_string_append_newline_indent (g, indent+1);
g = xml_tree_dump_node_indent (g, child, nl, indent+1);
} |
if (nl < g->len) nl = g->len + 1;
g = g_string_append_newline_indent (g, indent);
} |
if (! node->name) goto done;
if (node->name[0] == '<') goto done;
if (nl < g->len && ! node->children)
g_string_append_newline_indent (g, indent);
g = g_string_append (g, "</");
g = g_string_append (g, node->name);
g = g_string_append_c (g, '>');
if (nl < g->len && node->children)
{
g_string_append_newline_indent (g, indent);
xml_tree_dump_node_links (g, node);
} |
done:
return g;
} |
|