|
|
|
@ -12,9 +12,9 @@ |
|
|
|
| obtain it through the world-wide-web, please send a note to | |
|
|
|
| license@php.net so we can mail you a copy immediately. | |
|
|
|
+----------------------------------------------------------------------+ |
|
|
|
| Author: Sterling Hughes <sterling@php.net> | |
|
|
|
| Marcus Boerger <helly@php.net> | |
|
|
|
| Rob Richards <rrichards@php.net> | |
|
|
|
| Authors: Sterling Hughes <sterling@php.net> | |
|
|
|
| Marcus Boerger <helly@php.net> | |
|
|
|
| Rob Richards <rrichards@php.net> | |
|
|
|
+----------------------------------------------------------------------+ |
|
|
|
*/ |
|
|
|
|
|
|
|
@ -268,7 +268,7 @@ change_node_zval(xmlNodePtr node, zval *value) |
|
|
|
xmlNodeSetContentLen(node, Z_STRVAL_P(value), Z_STRLEN_P(value)); |
|
|
|
break; |
|
|
|
default: |
|
|
|
php_error(E_WARNING, "It is not yet possible to assign complex types to attributes"); |
|
|
|
php_error(E_WARNING, "It is not possible to assign complex types to nodes"); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -770,32 +770,70 @@ SXE_METHOD(xpath) |
|
|
|
*/ |
|
|
|
SXE_METHOD(asXML) |
|
|
|
{ |
|
|
|
php_sxe_object *sxe; |
|
|
|
xmlChar *strval; |
|
|
|
char *filename; |
|
|
|
int filename_len; |
|
|
|
php_sxe_object *sxe; |
|
|
|
xmlNodePtr node; |
|
|
|
xmlOutputBufferPtr outbuf; |
|
|
|
xmlChar *strval; |
|
|
|
int strval_len; |
|
|
|
char *filename; |
|
|
|
int filename_len; |
|
|
|
|
|
|
|
if (ZEND_NUM_ARGS() > 1) { |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
|
|
|
|
if (ZEND_NUM_ARGS() == 1) { |
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); |
|
|
|
|
|
|
|
xmlSaveFile(filename, (xmlDocPtr) sxe->document->ptr); |
|
|
|
|
|
|
|
RETURN_TRUE; |
|
|
|
} |
|
|
|
if (ZEND_NUM_ARGS() != 0) { |
|
|
|
RETURN_FALSE; |
|
|
|
GET_NODE(sxe, node); |
|
|
|
|
|
|
|
if (node) { |
|
|
|
if (XML_DOCUMENT_NODE == node->parent->type) { |
|
|
|
xmlSaveFile(filename, (xmlDocPtr) sxe->document->ptr); |
|
|
|
} else { |
|
|
|
outbuf = xmlOutputBufferCreateFilename(filename, NULL, 0); |
|
|
|
|
|
|
|
if (outbuf == NULL) { |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
|
|
|
|
xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 1, NULL); |
|
|
|
xmlOutputBufferClose(outbuf); |
|
|
|
RETURN_TRUE; |
|
|
|
} |
|
|
|
} else { |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); |
|
|
|
xmlDocDumpMemory((xmlDocPtr) sxe->document->ptr, &strval, &Z_STRLEN_P(return_value)); |
|
|
|
Z_STRVAL_P(return_value) = estrndup(strval, Z_STRLEN_P(return_value)); |
|
|
|
xmlFree(strval); |
|
|
|
GET_NODE(sxe, node); |
|
|
|
|
|
|
|
if (node) { |
|
|
|
if (XML_DOCUMENT_NODE == node->parent->type) { |
|
|
|
xmlDocDumpMemory((xmlDocPtr) sxe->document->ptr, &strval, &strval_len); |
|
|
|
} else { |
|
|
|
/* Should we be passing encoding information instead of NULL? */ |
|
|
|
outbuf = xmlAllocOutputBuffer(NULL); |
|
|
|
|
|
|
|
Z_TYPE_P(return_value) = IS_STRING; |
|
|
|
if (outbuf == NULL) { |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
|
|
|
|
xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 1, ((xmlDocPtr) sxe->document->ptr)->encoding); |
|
|
|
xmlOutputBufferFlush(outbuf); |
|
|
|
strval = xmlStrndup(outbuf->buffer->content, outbuf->buffer->use); |
|
|
|
xmlOutputBufferClose(outbuf); |
|
|
|
} |
|
|
|
|
|
|
|
RETVAL_STRINGL(strval, strlen(strval), 1); |
|
|
|
xmlFree(strval); |
|
|
|
} else { |
|
|
|
RETVAL_FALSE; |
|
|
|
} |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
|
|
|
|
|