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

From: Date: Tue, 25 Apr 2017 07:25:34 +0000
Subject: Bug #74494 [Nab]: DOMDocument::saveXML() LIBXML_NOEMPTYTAG option is ignored
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208771@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 Updated by: requinix@php.net Reported by: mfburdett at gmail dot com Summary: DOMDocument::saveXML() LIBXML_NOEMPTYTAG option is ignored Status: Not a bug Type: Bug Package: DOM XML related Operating System: FreeBSD PHP Version: 7.1.4 Block user comment: N Private report: N New Comment: Looks fine to me. https://3v4l.org/pOKD9 What libxml do you have? Previous Comments: ------------------------------------------------------------------------ [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(). ------------------------------------------------------------------------ [2017-04-24 18:11:06] mfburdett at gmail dot com Description: ------------ When executing a PHP script using the Apache module, the DOMDocument::saveXML() LIBXML_NOEMPTYTAG option is ignored - a self-closing tag, e.g. <body /> is created. When executing the same script on the commandline, the LIBXML_NOEMPTYTAG option is honored. This could be a bug in how PHP, Apache and LibXML are compiled by FreeBSD ports, rather than a bug in PHP itself. Test script: --------------- <?php $dom = new \DOMDocument(); $dom->loadHTML('<body></body>'); $node = $dom->getElementsByTagName('body')->item(0); echo $dom->saveXML($node, LIBXML_NOEMPTYTAG); Expected result: ---------------- <body></body> Actual result: -------------- <body/> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74494&edit=1

« previous php.bugs (#208771) next »