略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: DOMNode::normalize

2024-11-14

DOMNode::normalize

(PHP 5, PHP 7, PHP 8)

DOMNode::normalize Normalizes the node

说明

public DOMNode::normalize(): void

Remove empty text nodes and merge adjacent text nodes in this node and all its children.

参数

此函数没有参数。

返回值

没有返回值。

add a noteadd a note

User Contributed Notes 1 note

up
2
Amir Laher
16 years ago
This is a quote from the DOM level 2 spec, explaining the normalize() function.
----
normalize
Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer [XPointer] lookups) that depend on a particular document tree structure are to be used.
----
(source: http://www.w3.org/TR/DOM-Level-2-Core/core.html)

i.e. the idea of normalize is to make text nodes the same as they would be if the xml document was re-loaded into DOM. It's handy if you want to compare DOM nodes.

官方地址:https://www.php.net/manual/en/domnode.normalize.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3