php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33261 createElement('param') dosn't add </param> tag
Submitted: 2005-06-07 11:47 UTC Modified: 2005-06-07 13:15 UTC
From: breakpoint at gazeta dot pl Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.0.3 OS: Linux Slackware 10
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: breakpoint at gazeta dot pl
New email:
PHP Version: OS:

 

 [2005-06-07 11:47 UTC] breakpoint at gazeta dot pl
Description:
------------
DOM in PHP5 eating ( ;-) ) close tag when I add tag <param>. I expected <param ..></param> or <param/>. but DOM get <param> with out </param> :-(

Sorry for my english - look in Reproduce code, and Expected and Actual results.

Reproduce code:
---------------
<?php
$objDOM = new DOMDocument();

$objConfig = $objDOM->createElement('config');
$objDOM->appendChild($objConfig);

$objSettings = $objDOM->createElement('settings');
$objConfig->appendChild($objSettings);

for($i=0; $i<10; $i++) {
	$objParam = $objDOM->createElement('param'); //HERE!!
	$objParam->SetAttribute('name', '11');
	$objParam->SetAttribute('value', '22');
	$objConfig->appendChild($objParam);
}

echo htmlspecialchars($objDOM->saveHTML());
?>

Expected result:
----------------
<config><settings></settings><param name="11" value="22"></param><param name="11" value="22"></param><param name="11" value="22"></param><param name="11" value="22"></param><param name="11" value="22"></param><param name="11" value="22"></param><param name="11" value="22"></param><param name="11" value="22"></param><param name="11" value="22"></param><param name="11" value="22"></param></config>

Actual result:
--------------
<config><settings></settings><param name="11" value="22"> <param name="11" value="22"> <param name="11" value="22"> <param name="11" value="22"> <param name="11" value="22"> <param name="11" value="22"> <param name="11" value="22"> <param name="11" value="22"> <param name="11" value="22"> <param name="11" value="22"></config>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-07 11:55 UTC] breakpoint at gazeta dot pl
I forget, whe we change line
$objParam = $objDOM->createElement('param'); //HERE!!
to for example
$objParam = $objDOM->createElement('params'); //HERE!!

sampel work fine...
 [2005-06-07 13:15 UTC] chregu@php.net
no wonder, if you use saveHTML(). use saveXML() and everything works fine. saveHTML() is meant to be used on HTML4 documents, where param has a special meaning and is a tag which is not supposed to be closed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 12:01:27 2024 UTC