diff options
author | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2011-10-10 16:20:07 +0200 |
---|---|---|
committer | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2011-10-10 16:31:03 +0200 |
commit | 7b1aa28c2c692d74abf7ed030721a29ea7f5cfa2 (patch) | |
tree | 3e7b13c73df27449d651c22d01810a84b1ed8651 /lasso/xml | |
parent | 627294f52c045caecaced1cf42793f2ace1f0179 (diff) | |
download | lasso-7b1aa28c2c692d74abf7ed030721a29ea7f5cfa2.tar.gz lasso-7b1aa28c2c692d74abf7ed030721a29ea7f5cfa2.tar.xz lasso-7b1aa28c2c692d74abf7ed030721a29ea7f5cfa2.zip |
[xml] allows LassoMiscText.init_from_xml to parse any xmlNode
If the node has no attributes and has a simple string content, we use the
classic embedding by setting, name, ns_href, ns_prefix. Otherwise the complete
xmlNode is copied.
Diffstat (limited to 'lasso/xml')
-rw-r--r-- | lasso/xml/misc_text_node.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lasso/xml/misc_text_node.c b/lasso/xml/misc_text_node.c index 1450cb71..1cbaa675 100644 --- a/lasso/xml/misc_text_node.c +++ b/lasso/xml/misc_text_node.c @@ -95,15 +95,21 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode) n->text_child = TRUE; n->content = g_strdup((char*)(xmlnode->content)); return 0; + } else if (xmlnode->type == XML_ELEMENT_NODE && xmlnode->properties == NULL && + (xmlnode->children == NULL + || (xmlnode->children != NULL && xmlnode->children->next == NULL && + xmlnode->children->type == XML_TEXT_NODE))) + { + rc = parent_class->init_from_xml(node, xmlnode); + if (rc) return rc; + + n->ns_href = g_strdup((char*)xmlnode->ns->href); + n->ns_prefix = g_strdup((char*)xmlnode->ns->prefix); + n->name = g_strdup((char*)xmlnode->name); + } else { + lasso_misc_text_node_set_xml_content(n, xmlnode); } - rc = parent_class->init_from_xml(node, xmlnode); - if (rc) return rc; - - n->ns_href = g_strdup((char*)xmlnode->ns->href); - n->ns_prefix = g_strdup((char*)xmlnode->ns->prefix); - n->name = g_strdup((char*)xmlnode->name); - return 0; } |