php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51530 DOMDocument::createElement() does not handle <link> correctly
Submitted: 2010-04-11 02:16 UTC Modified: 2010-04-12 16:41 UTC
From: jameswithers89 at googlemail dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.3.2 OS: Fedora 12 GNU/Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jameswithers89 at googlemail dot com
New email:
PHP Version: OS:

 

 [2010-04-11 02:16 UTC] jameswithers89 at googlemail dot com
Description:
------------
DOMDocument::createElement() does not add a closing </link> tag with DOMDocument::createElement('link'). It outputs <element> rather than <element></element>.

I am using php-5.3.2-1.fc12.i686 and php-xml-5.3.2-1.fc12.i686 installed using Yellowdog Updater, Modified Package Manager. All other DOM methods tried so far work fine.

Test script:
---------------
<?php
$implementation = new DOMImplementation();
$document = $implementation->createDocument(null, null, $implementation->createDocumentType('html'));
$html = $document->createElement('html');
$head = $document->createElement('head');
$stylesheet = $document->createElement('link');
$title = $document->createElement('title', 'Possible link error');
$body = $document->createElement('body');
$html->setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
$stylesheet->setAttribute('href','style.css');
$stylesheet->setAttribute('rel','stylesheet');
$stylesheet->setAttribute('type','text/css');
$document->appendChild($html);
$html->appendChild($head);
$html->appendChild($body);
$head->appendChild($stylesheet);
$head->appendChild($title);
echo $document->saveHTML();

Expected result:
----------------
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="style.css" rel="stylesheet" type="text/css"></link>
<title>Possible link error</title>
</head>
<body></body>
</html>

Actual result:
--------------
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<title>Possible link error</title>
</head>
<body></body>
</html>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-12 16:41 UTC] rrichards@php.net
-Status: Open +Status: Bogus
 [2010-04-12 16:41 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

use saveXML to produce XHTML. In regular HTML link tag has no closing tag
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 06:01:32 2025 UTC