Bug #74494 [Opn]: DOMDocument::saveXML() LIBXML_NOEMPTYTAG option is ignored

From: Date: Tue, 25 Apr 2017 22:10:49 +0000
Subject: Bug #74494 [Opn]: DOMDocument::saveXML() LIBXML_NOEMPTYTAG option is ignored
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208800@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74494&edit=1

 ID:                 74494
 User updated by:    mfburdett at gmail dot com
 Reported by:        mfburdett at gmail dot com
 Summary:            DOMDocument::saveXML() LIBXML_NOEMPTYTAG option is
                     ignored
 Status:             Open
 Type:               Bug
 Package:            DOM XML related
 Operating System:   FreeBSD
 PHP Version:        7.1.4
 Block user comment: N
 Private report:     N

 New Comment:

I resolved this issue by purging old libraries in /usr/local/lib/compat/pkg (libraries are
automatically moved here when packages are uninstalled) and forcibly recompiling and reinstalling
all dependencies: portupgrade -fR textproc/php71-dom www/mod_php71

I didn't try to debug, but perhaps an old version of libxml was used despite PHP reporting
libxml 2.9.4?

I think this bug could be closed again since it is resolvable, but hope this report is useful to
someone else who runs into this obscure issue...


Previous Comments:
------------------------------------------------------------------------
[2017-04-25 20:57:57] requinix@php.net

I haven't found anything to suggest why yours is working differently. I'm still pretty
sure this is not a bug with PHP but I don't know enough to tell you what to test next (besides
maybe a build straight from the libxml2 sources without FreeBSD's patches?) so I'll move
this back to Open.

------------------------------------------------------------------------
[2017-04-25 19:02:42] mfburdett at gmail dot com

phpinfo reports libxml 2.9.4

------------------------------------------------------------------------
[2017-04-25 07:25:32] requinix@php.net

Looks fine to me. https://3v4l.org/pOKD9

What libxml do you have?

------------------------------------------------------------------------
[2017-04-25 00:03:53] mfburdett at gmail dot com

I can also reproduce this bug with an XML document:

<?php
$dom = new \DOMDocument();
$dom->loadXML('<root><node/></root>');
$node = $dom->getElementsByTagName('node')->item(0);
echo $dom->saveXML($node, LIBXML_NOEMPTYTAG);

Expected result: <node></node>

Actual result: <node/>

------------------------------------------------------------------------
[2017-04-24 19:05:19] requinix@php.net

LIBXML_NOEMPTYTAG only applies to XML documents. Yours is HTML.

Use ->saveHTML().

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=74494


--
Edit this bug report at https://bugs.php.net/bug.php?id=74494&edit=1


Thread (8 messages)

« previous php.bugs (#208800) next »