diff options
author | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2010-06-29 14:15:08 +0000 |
---|---|---|
committer | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2010-06-29 14:15:08 +0000 |
commit | 35347922850c0c3435e7ed55597aba02d219d68c (patch) | |
tree | fa20b95112cdc7d5fc4aed97b30241c4e94ab677 /bindings/php5/wrapper_source_top.c | |
parent | 2e9e814b0900dae14e291ee7708ee92b4035c019 (diff) | |
download | lasso-35347922850c0c3435e7ed55597aba02d219d68c.tar.gz lasso-35347922850c0c3435e7ed55597aba02d219d68c.tar.xz lasso-35347922850c0c3435e7ed55597aba02d219d68c.zip |
[Bindings] accept simple string in string<->xmlNode converter
Some use case ask for passing simple libxml content node (i.e just an
UTF-8 string) when a method argument or a field of the xmlNode* type.
This commit add a static method in bindings/utils.c named
lasso_string_fragment_to_xmlnode which does this transform by trying to
parse an XML document then by trying to parse a well balanced XML
fragment of only one node (if there is more than one node such as in the
string " xxx <tag/> yyy ", we free the node list and return NULL).
Diffstat (limited to 'bindings/php5/wrapper_source_top.c')
-rw-r--r-- | bindings/php5/wrapper_source_top.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/bindings/php5/wrapper_source_top.c b/bindings/php5/wrapper_source_top.c index ebb8eb62..1b6bec7e 100644 --- a/bindings/php5/wrapper_source_top.c +++ b/bindings/php5/wrapper_source_top.c @@ -8,6 +8,7 @@ #include "php_lasso.h" #include "../ghashtable.h" #include "../../lasso/utils.h" +#include "../utils.c" /* utility functions */ static void free_glist(GList **list, GFunc free_function); @@ -126,17 +127,7 @@ get_string_from_xml_node(xmlNode *xmlnode) static xmlNode* get_xml_node_from_string(char *string) { - xmlDoc *doc; - xmlNode *node; - - doc = xmlReadDoc((xmlChar*)string, NULL, NULL, XML_PARSE_NONET); - node = xmlDocGetRootElement(doc); - if (node != NULL) { - node = xmlCopyNode(node, 1); - } - lasso_release_doc(doc); - - return node; + return lasso_string_fragment_to_xmlnode(string, 0); } static GList* |