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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
43 - 7 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC