php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43514 writelement warning
Submitted: 2007-12-06 10:22 UTC Modified: 2007-12-06 12:28 UTC
From: stem at chalmers dot se Assigned:
Status: Not a bug Package: XML Writer
PHP Version: 5.2.5 OS: Vista 32
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: stem at chalmers dot se
New email:
PHP Version: OS:

 

 [2007-12-06 10:22 UTC] stem at chalmers dot se
Description:
------------
issues a warning when passing an array value as "The element name"

Reproduce code:
---------------
<?php   
    $test = array('foo','bar');
    $testarr = array('foo' => array('1','2','3'),'bar' => array('1','2','3'));    
    $titles = array('item_1', 'item_2');
        
    header('Content-Type: text/xml; charset=iso-8859-1');
    
    $xml = new xmlWriter();
    $xml->openMemory();
    $xml->setindent(true);
    $xml->setindentstring('  ');
    $xml->startDocument('1.0','iso-8859-1');
    $xml->startElement ('root');          
    for($i=0;$i<count($test);$i++) {                     
        $xml->writeElement ('title', $test[$i]);
        $xml->startElement ('data');
        for($j=0;$j<count($testarr[$test[$i]]);$j++) {
            $xml->writeElement ($titles[$j], 'test');    
        }
        $xml->endElement();
    }
                
    $xml->endElement();
    print $xml->outputMemory(true); 
?>

Expected result:
----------------
No warning.

Actual result:
--------------
<b>Warning</b>:  XMLWriter::writeElement() [<a href='function.XMLWriter-writeElement'>function.XMLWriter-writeElement</a>]: Invalid Element Name in <b>D:\devel\bug\index.php</b> on line <b>18</b>

However the xmldata is printed correctley if the source is checked.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-06 12:28 UTC] rrichards@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

If you actually looked at the notices being generated you would see your script is buggy and you are passing bad values to writeElement
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC