php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29911 DOMDocuments are always equal.
Submitted: 2004-08-31 12:59 UTC Modified: 2004-08-31 13:40 UTC
From: wb at pro-net dot co dot uk Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.0.1 OS: FreeBSD 5.2.1
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: wb at pro-net dot co dot uk
New email:
PHP Version: OS:

 

 [2004-08-31 12:59 UTC] wb at pro-net dot co dot uk
Description:
------------
Different DOMDocuments are always equal even if the 'XML' is different.



Reproduce code:
---------------
<?php
$dom1 = new DOMDocument();
$dom1->loadXML("<root><node/></root>");

$dom2 = new DOMDocument();
$dom2->loadXML("<root><node/></root>");

$dom3 = new DOMDocument();
$dom3->loadXML("<root><node type=\"blah\"/></root>");

if($dom1 == $dom2){
    print("dom1 == dom2\n");
}else{
    print("dom1 != dom2\n");
}

if($dom1 == $dom3){
    print("dom1 == dom3\n");
}else{
    print("dom1 != dom3\n");
}

?>

Expected result:
----------------
dom1 == dom2
dom1 != dom3

Actual result:
--------------
dom1 == dom2
dom1 == dom3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-31 13:40 UTC] chregu@php.net
That's (with every object in PHP) expected behaviour.

Although

$dom->saveXML() == $dom2->saveXML()

should work
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 02 18:01:28 2025 UTC