| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2005-02-20 14:20 UTC] rrichards@php.net
  | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 10:00:02 2025 UTC | 
Description: ------------ $doc->preserveWhiteSpace = false; works fine up to the point when I try to load external XML file. why is it so important? firstChild, previousSibling are DOMText so I have to use getElementsByTagName() which is much slower... especially when I know that the node I'm interested in is firstChild (XSD schema) the $pFileName points to XML file eg. <Programmers> <Programmer> <firstName>Łukasz</firstName> <lastName>Budnik</lastName> </Programmer> </Programmers> my DOM: DOM/XML enabled DOM/XML API Version 20031129 libxml Version 2.6.6 HTML Support enabled XPath Support enabled XPointer Support enabled Schema Support enabled RelaxNG Support enabled Reproduce code: --------------- // up to this point whitespaces are OK // $doc->preserveWhiteSpace = false; // load new DomDocument $tmpXml = DomDocument::load($pFileName); // preserve whitespaces $tmpXml->preserveWhiteSpace = false; $tmpNode = $tmpXml->documentElement; $contents->appendChild($doc->importNode($tmpNode, true))); Expected result: ---------------- <?xml version="1.0" encoding="ISO-8859-2"?> <xhp><properties><Page>index</Page><Module>main</Module><contents><Programmers><Programmer><firstName>Łukasz</firstName><lastName>Budnik</lastName></Programmer></Programmers></contents></xhp> Actual result: -------------- <?xml version="1.0" encoding="ISO-8859-2"?> <xhp><properties><Page>index</Page><Module>main</Module><contents><Programmers> <Programmer> <firstName>Łukasz</firstName> <lastName>Budnik</lastName> </Programmer> </Programmers></contents></xhp>