php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43754 XMLWriter::fullEndElement produces wrong indentation
Submitted: 2008-01-04 21:20 UTC Modified: 2008-01-09 09:47 UTC
From: karel dot smutny at gmail dot com Assigned:
Status: Closed Package: XML Writer
PHP Version: 5.2.5 OS: Windows XP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: karel dot smutny at gmail dot com
New email:
PHP Version: OS:

 

 [2008-01-04 21:20 UTC] karel dot smutny at gmail dot com
Description:
------------
fullEndElement() procedure produces wrong indentation when called setIndent(true). There is no new line and indentation before tag  following another end tag produced by fullEndElement().

Reproduce code:
---------------
  $xml = new XMLWriter();
  $xml->openMemory();
  $xml->setIndent(true);
  
  $xml->startElement('body');
  $xml->startElement('div');
  $xml->writeAttribute('id', 'all');
  $xml->startElement('div');
  $xml->writeAttribute('id', 'header');
  $xml->fullEndElement();
  $xml->startElement('div');
  $xml->writeAttribute('id', 'content');
  $xml->fullEndElement();
  $xml->startElement('div');
  $xml->writeAttribute('id', 'footer');
  $xml->fullEndElement();
  $xml->fullEndElement();
  $xml->fullEndElement();
  echo $xml->outputMemory();

Expected result:
----------------
<body>
 <div id="all">
  <div id="header"></div>  
  <div id="content"></div>  
  <div id="footer"></div>
 </div>
</body>

Actual result:
--------------
<body>
 <div id="all">
  <div id="header"></div>  <div id="content"></div>  <div id="footer"></div></div></body>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-08 21:13 UTC] felipe@php.net
AFAIK, this is a bug in Libxml. Seeing the source in 
http://cvs.gnome.org/viewcvs/libxml2/xmlwriter.c?rev=1.37&view=markup
in xmlTextWriterFullEndElement() is missing:

    if (writer->indent) {
        count = xmlOutputBufferWriteString(writer->out, "\n");
        sum += count;
    }

That is founded in xmlTextWriterEndElement() (called from endElement() in PHP extension), and works fine. :)
 [2008-01-09 09:47 UTC] felipe@php.net
I reported this bug, and already fixed in SVN (libxml).

http://bugzilla.gnome.org/show_bug.cgi?id=508156
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 08 17:03:38 2021 UTC