summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSterling Hughes <sterling@php.net>2003-05-26 01:41:25 (GMT)
committerSterling Hughes <sterling@php.net>2003-05-26 01:41:25 (GMT)
commitfb14866796a696aea07434ff935f2da2efdcf687 (patch)
treee6916ccca3f15b99f7fe7f4fad869f21e0855b49
parent1410e818470b521a347460176b457c44b43a57c7 (diff)
downloadphp-fb14866796a696aea07434ff935f2da2efdcf687.tar.gz
add a new function simplexml_load_string()
-rw-r--r--ext/simplexml/simplexml.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 54abedf..cb0e9a4 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -578,6 +578,29 @@ PHP_FUNCTION(simplexml_load_file)
}
/* }}} */
+/* {{{ proto simplemxml_element simplexml_load_string(string data)
+ Load a string and return a simplexml_element object to allow for processing */
+PHP_FUNCTION(simplexml_load_string)
+{
+ php_sxe_object *sxe;
+ char *data;
+ int data_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) {
+ return;
+ }
+
+ sxe = php_sxe_object_new(TSRMLS_C);
+ sxe->document = xmlParseMemory(data, data_len);
+ if (sxe->document == NULL) {
+ RETURN_FALSE;
+ }
+
+ return_value->type = IS_OBJECT;
+ return_value->value.obj = php_sxe_register_object(sxe TSRMLS_CC);
+}
+/* }}} */
+
/* {{{ proto bool simplexml_save_document_file(string filename, simplexml_element node)
Save a XML document to a file from a SimpleXML node */
PHP_FUNCTION(simplexml_save_document_file)
@@ -623,6 +646,7 @@ PHP_FUNCTION(simplexml_save_document_string)
function_entry simplexml_functions[] = {
PHP_FE(simplexml_load_file, NULL)
+ PHP_FE(simplexml_load_string, NULL)
PHP_FE(simplexml_save_document_file, NULL)
PHP_FE(simplexml_save_document_string, first_arg_force_ref)
{NULL, NULL, NULL}