List Info

Thread: note 61602 added to ref.dom




note 61602 added to ref.dom
user name
2006-02-07 17:47:27
For those of you suffering with extra DOMText objects in
your DOM Tree, set preserveWhiteSpace to false before
loading your XML. This doesn't seem to be explicitly stated
in the manual.

Example:
<?php
$dom = new DOMDocument();
$xml = '<?xml version="1.0"
encoding="UTF-8"?>
<node1>
 <node2 />
</node1>
';
$dom->loadXML( $xml );
$nodeList = $dom->getElementsByTagName( 'node1' );
$node1 = $nodeList->item(0);
foreach ( $node1->childNodes as $node ) {
    echo 'Class: ' . get_class( $node ) . "n";
}
?>

Will result in:
Class: DOMText
Class: DOMElement
Class: DOMText

If you add:
<?php
$dom->preserveWhiteSpace = false;
?>

You will get:
Class: DOMElement
----
Server IP: 216.194.113.175
Probable Submitter: 65.117.161.228
----
Manual Page -- http://www.p
hp.net/manual/en/ref.dom.php
Edit        -- http://master.php.net/manage/user-notes.php?action=
edit+61602
Delete: added to the manual -- htt
p://master.php.net/manage/user-notes.php?action=delete+61602
&report=yes&reason=added+to+the+manual
Delete: bad code            -- http://master.
php.net/manage/user-notes.php?action=delete+61602&report
=yes&reason=bad+code
Delete: spam                -- http://master.php.
net/manage/user-notes.php?action=delete+61602&report=yes
&reason=spam
Delete: useless             -- http://master.p
hp.net/manage/user-notes.php?action=delete+61602&report=
yes&reason=useless
Delete: non-english         -- http://mast
er.php.net/manage/user-notes.php?action=delete+61602&rep
ort=yes&reason=non-english
Delete: already in docs     -- http://
master.php.net/manage/user-notes.php?action=delete+61602&
;report=yes&reason=already+in+docs
Delete: other reasons       -- http://master.php.net/manage/user-
notes.php?action=delete+61602&report=yes
Reject      -- http://master.php.net/manage/user-
notes.php?action=reject+61602&report=yes
Search      -- http://ma
ster.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

note 61602 deleted from ref.dom by didou
user name
2006-03-13 00:06:34
Note Submitter: kermodebear at kermodebear dot org 

----

For those of you suffering with extra DOMText objects in
your DOM Tree, set preserveWhiteSpace to false before
loading your XML. This doesn't seem to be explicitly stated
in the manual.

Example:
<?php
$dom = new DOMDocument();
$xml = '<?xml version="1.0"
encoding="UTF-8"?>
<node1>
 <node2 />
</node1>
';
$dom->loadXML( $xml );
$nodeList = $dom->getElementsByTagName( 'node1' );
$node1 = $nodeList->item(0);
foreach ( $node1->childNodes as $node ) {
    echo 'Class: ' . get_class( $node ) .
"\n";
}
?>

Will result in:
Class: DOMText
Class: DOMElement
Class: DOMText

If you add:
<?php
$dom->preserveWhiteSpace = false;
?>

You will get:
Class: DOMElement

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )