Create a XML node from an AtomPerson
[cascardo/atompub.git] / atom / person.c
index 6b63ec4..62f9ed4 100644 (file)
@@ -20,6 +20,7 @@
 #include <atompub/atom.h>
 
 #include <glib.h>
+#include <libxml/tree.h>
 
 struct _atom_person
 {
@@ -92,3 +93,16 @@ atom_person_email_set (AtomPerson *person, char *email)
     g_free (person->email);
   person->email = g_strdup (email);
 }
+
+xmlNodePtr
+atom_person_to_xmlnode (AtomPerson *person, char *elname)
+{
+  xmlNodePtr node;
+  node = xmlNewNode (NULL, elname);
+  xmlNewTextChild (node, NULL, "name", person->name);
+  if (person->uri)
+    xmlNewTextChild (node, NULL, "uri", iri_get_string (person->uri));
+  if (person->email)
+    xmlNewTextChild (node, NULL, "email", person->email);
+  return node;
+}