+ AtomContent *content;
+ xmlDocPtr doc;
+ xmlNodePtr root;
+ xmlNodePtr child;
+ doc = xmlReadMemory (buffer, len, NULL, NULL,
+ XML_PARSE_RECOVER | XML_PARSE_NOERROR);
+ if (doc == NULL || (root = xmlDocGetRootElement (doc)) == NULL)
+ return NULL;
+ if (xmlStrcmp (root->name, "content"))
+ {
+ xmlFreeDoc (doc);
+ return NULL;
+ }
+ content = g_slice_new0 (AtomContent);
+ if ((content->type = xmlGetProp (root, "type")) == NULL)
+ {
+ g_slice_free (AtomContent, content);
+ xmlFreeDoc (doc);
+ return NULL;
+ }
+ content->src = xmlGetProp (root, "src");
+ if (content->src == NULL)
+ {
+ /* libxml2 does not help a lot here. We must decide between a
+ XML child or a content child. Using the type attribute might
+ be a good idead. Let's just ask that the current method
+ works. */
+ if (root->children && root->children->type == XML_ELEMENT_NODE)
+ {
+ content->xmlcontent = xmlCopyNodeList (root->children);
+ }
+ else
+ {
+ content->content = xmlNodeGetContent (root);
+ content->content_len = xmlStrlen (content->content);
+ }
+ }
+ xmlFreeDoc (doc);
+ return content;