xml_write
)
and the other writes just the content of the element (xml_writecontent
).
XMLAPI void xml_write (FILE * file, XML * xml) { ATTR * attr; ELEMENTLIST * list; |
if (xml->name == NULL) { fprintf (file, "%s", xml->attrs->value); return; } |
fprintf (file, "<%s", xml->name); attr = xml->attrs; while (attr != NULL) { fprintf (file, " %s=\"%s\"", attr->name, attr->value); attr = attr->next; } |
if (xml->children == NULL) { fprintf (file, "/>"); return; } else fprintf (file, ">"); |
xml_writecontent (file, xml); |
fprintf (file, "</%s>", xml->name); } |
XMLAPI void xml_writecontent (FILE * file, XML * xml) { ELEMENTLIST * list; list = xml->children; while (list) { xml_write (file, list->element); list = list->next; } } |
XMLAPI void xml_writehtml (FILE * file, XML * xml) { ATTR * attr; ELEMENTLIST * list; if (xml->name == NULL) { fprintf (file, "%s", xml->attrs->value); return; } fprintf (file, "<%s", xml->name); attr = xml->attrs; while (attr != NULL) { fprintf (file, " %s=\"%s\"", attr->name, attr->value); attr = attr->next; } |
fprintf (file, ">"); if (xml->children == NULL) { if (!strcmp (xml->name, "p") || !strcmp (xml->name, "a")) { fprintf (file, "</%s>", xml->name); } return; } xml_writecontenthtml (file, xml); |
if (!strcmp (xml->name, "li") || !strcmp (xml->name, "opt")) { } else fprintf (file, "</%s>", xml->name); } |
XMLAPI void xml_writecontenthtml (FILE * file, XML * xml) { ELEMENTLIST * list; list = xml->children; while (list) { xml_writehtml (file, list->element); list = list->next; } } |
XMLAPI int xml_output (char * f, XML * xml, int mode) { FILE * file; file = fopen (f, "w"); if (!file) return 0; switch (mode) { case 1: xml_writecontent (file, xml); break; case 2: xml_writehtml (file, xml); break; case 3: xml_writecontenthtml (file, xml); break; default: xml_write (file, xml); break; } fclose (file); return 1; } |
This code and documentation are released under the terms of the GNU license. They are additionally copyright (c) 2000, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license. This presentation was created using LPML. |