]> granicus.if.org Git - php/commitdiff
allow the root element to be accessed as a text node
authorSterling Hughes <sterling@php.net>
Wed, 25 Jun 2003 16:26:32 +0000 (16:26 +0000)
committerSterling Hughes <sterling@php.net>
Wed, 25 Jun 2003 16:26:32 +0000 (16:26 +0000)
ext/simplexml/simplexml.c

index 3cee43d9696a36ce7346b7f9d7081df7ecbed3cf..19db746844243531fc590c7660fffafc4cbae285 100644 (file)
@@ -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);