php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32033 preserveWhiteSpace and impoted nodes dosn't work
Submitted: 2005-02-20 10:59 UTC Modified: 2005-02-20 14:20 UTC
From: xhemjl at tlen dot pl Assigned:
Status: Not a bug Package: XML related
PHP Version: 5.0.2 OS: 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: xhemjl at tlen dot pl
New email:
PHP Version: OS:

 

 [2005-02-20 10:59 UTC] xhemjl at tlen dot pl
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>&#321;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>&#321;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>&#321;ukasz</firstName>
                <lastName>Budnik</lastName>
        </Programmer>
</Programmers></contents></xhp>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-20 14:20 UTC] rrichards@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC