note 79068 deleted from ref.simplexml by danbrown

From: Date: Mon, 18 May 2009 01:17:10 +0000
Subject: note 79068 deleted from ref.simplexml by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155508@lists.php.net to get a copy of this message
Note Submitter: jevon at jevon dot org ---- If you want to compare two XML documents for loose equality -- i.e. they both have the same attributes, children and text content, over all namespaces -- then you can use the function provided below. I don't know of any easier way to do this -- it would make sense to be part of the SimpleXML extension, I'm sure. <?php $xml1 = new SimpleXMLElement(file_get_contents('file1.xml')); $xml2 = new SimpleXMLElement(file_get_contents('file2.xml')); $result = xml_is_equal($xml1, $xml2); if ($result === true) { // the XML documents are the same } else { // they are different: print the reason why printf(STDERR, "XML documents are different: $result"); } ?> xml_is_equal() source: http://www.jevon.org/wiki/Comparing_Two_SimpleXML_Documents

« previous php.notes (#155508) next »