From: Sterling Hughes Date: Wed, 25 Jun 2003 16:26:32 +0000 (+0000) Subject: allow the root element to be accessed as a text node X-Git-Tag: RELEASE_1_0_2~51 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4f41fbb26c3e381adcb8f556618ce233b2bfd0a;p=php allow the root element to be accessed as a text node --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 3cee43d969..19db746844 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -738,12 +738,18 @@ sxe_object_cast(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_ zval_dtor(writeobj); } + if (!sxe->node) { + if (sxe->document) { + sxe->node = xmlDocGetRootElement((xmlDocPtr) sxe->document->ptr); + } + } + if (sxe->node) { contents = xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, sxe->node->children, 1); if (!xmlIsBlankNode(sxe->node->children) && contents) { cast_object(writeobj, type, NULL TSRMLS_CC); } - } + } cast_object(writeobj, type, contents TSRMLS_CC);