summaryrefslogtreecommitdiffstats
path: root/bindings/perl
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-06-29 14:15:08 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-06-29 14:15:08 +0000
commit35347922850c0c3435e7ed55597aba02d219d68c (patch)
treefa20b95112cdc7d5fc4aed97b30241c4e94ab677 /bindings/perl
parent2e9e814b0900dae14e291ee7708ee92b4035c019 (diff)
downloadlasso-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/perl')
-rw-r--r--bindings/perl/glist_handling.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/bindings/perl/glist_handling.c b/bindings/perl/glist_handling.c
index d36c59b0..4cb09740 100644
--- a/bindings/perl/glist_handling.c
+++ b/bindings/perl/glist_handling.c
@@ -27,6 +27,7 @@
#include <glib-object.h>
#include <lasso/xml/xml.h>
#include <lasso/utils.h>
+#include "../utils.c"
/**
* xmlnode_to_pv:
@@ -67,23 +68,15 @@ xmlnode_to_pv(xmlNode *node, gboolean do_free)
static xmlNode *
pv_to_xmlnode(SV *value) {
- char *string;
- xmlDoc *doc;
- xmlNode *node = NULL;
+ int size;
if (! SvPOK(value))
return NULL;
- string = SvPV_nolen(value);
+ string = SvPV(value, len);
if (! string)
return NULL;
- doc = xmlReadDoc(BAD_CAST string, NULL, NULL, XML_PARSE_NONET);
- if (! doc)
- return NULL;
- lasso_assign_xml_node(node, xmlDocGetRootElement(doc));
- lasso_release_doc(doc);
-
- return node;
+ return lasso_string_fragment_to_xmlnode(string, len);
}
/**