]> git.ozlabs.org Git - ccan/blobdiff - ccan/ttxml/ttxml.h
ttxml: removed cruft from tests
[ccan] / ccan / ttxml / ttxml.h
index 0b8c156d84d9907fdf4a2af3950f82d264552682..62d7c5096a1d4de2adcc373d2bd53d1c4bb875f4 100644 (file)
@@ -1,4 +1,36 @@
+#ifndef CCAN_TTXML_H
+#define CCAN_TTXML_H
 
+/**
+ * ttxml - tiny XML library for parsing (trusted!) XML documents.
+ *
+ * This parses an XML file into a convenient data structure.
+ *
+ * Example:
+ * #include <ccan/ttxml/ttxml.h>
+ * #include <stdio.h>
+ *
+ * int main(int argc, char *argv[])
+ * {
+ *     XmlNode *xml, *tmp;
+ *
+ *     xml = xml_load("./test/test.xml2");
+ *     if(!xml)return 1;
+ *
+ *     tmp = xml_find(xml, "childnode");
+ *
+ *     printf("%s: %s\n", xml->name, xml_attr(tmp, "attribute"));
+ *
+ *     xml_free(xml);
+ *
+ *     return 0;
+ * }
+ *
+ * Licensed under GPL - see LICENSE file for details.
+ * Author: Daniel Burke <dan.p.burke@gmail.com>
+ */
+
+/* Every node is one of these */
 typedef struct XmlNode {
        char * name;
        char ** attrib;
@@ -7,10 +39,19 @@ typedef struct XmlNode {
        struct XmlNode * next;
 } XmlNode;
 
+/* It's all pretty straight forward except for the attrib.
+ *
+ * Attrib is an array of char*, that is 2x the size of nattrib.
+ * Each pair of char* points to the attribute name & the attribute value,
+ * if present.
+ *
+ * If it's a text node, then name = "text", and attrib[1] = the body of text.
+ * This is the only case where there will be an attribute with a null name.
+ */
 
-XmlNode* xml_new(char * name, char * attrib);
 XmlNode* xml_load(const char * filename);
 void xml_free(XmlNode *target);
 char* xml_attr(XmlNode *x, const char *name);
 XmlNode * xml_find(XmlNode *xml, const char *name);
 
+#endif /* CCAN_TTXML_H */