GString*
xml_tree_dump_to_xml (xml_GNode* node, GString* g, int flag)
{
if (! g) g = g_string_new(0);
if (node->name)
{
switch (node->name[0])
{
case '<':
g_string_append (g, node->name);
break;
case '-':
if (!(XML_G_WITH_HIDDEN&flag)) goto done;
case ':':
if (! node->name[1]) break;
default:
g_string_append_c (g, '<');
g_string_append (g, node->name);
attr_list_string_append (g, node->attributes, flag);
if (node->end != node->off || !(XML_G_EMPTY_NODES&flag))
g_string_append_c (g, '>');
else
g_string_append (g, " />");
break;
} |
} |
if (node->children)
{
xml_GNode* child = node->children;
xml_GNode* print = 0;
for (; child ; child = child->next)
{
if (child->text)
{
if (print)
xml_g_string_append (g,
print->text->str + print->end, child->off - print->end);
else if (node->text)
xml_g_string_append (g,
node->text->str + node->off, child->off - node->off);
print = child;
} |
xml_tree_dump_to_xml (child, g, flag);
} |
if (node->text)
{
if (print)
xml_g_string_append (g,
node->text->str + print->end, node->end - print->end);
else
xml_g_string_append (g,
node->text->str + node->off, node->end - node->off);
} |
} | else{
if (node->text)
xml_g_string_append (g,
node->text->str + node->off, node->end - node->off);
} |
if (! node->name) goto done;
if (node->name[0] == '<') goto done;
if (node->name[0] == ':' && ! node->name[1]) goto done;
if (node->end != node->off || !(XML_G_EMPTY_NODES&flag))
{
g_string_append (g, "</");
g_string_append (g, node->name);
g_string_append_c (g, '>');
} |
done:
return g;
} |
|