PHP 8.4.1 Released!

DOMText::isWhitespaceInElementContent

(PHP 5, PHP 7, PHP 8)

DOMText::isWhitespaceInElementContent Indica se este nó de texto contém espaços em branco

Descrição

public DOMText::isWhitespaceInElementContent(): bool

Indica se este nó de texto contém apenas espaços em branco ou se está vazio. O nó de texto é considerado conter espaços em branco no conteúdo do elemento durante o carregamento do documento.

Parâmetros

Esta função não possui parâmetros.

Valor Retornado

Retorna true se o nó contiver zero ou mais caracteres de espaço em branco e nada mais. Retorna false caso contrário.

adicione uma nota

Notas Enviadas por Usuários (em inglês) 2 notes

up
2
permidion at yahoo dot com
20 years ago
if you have an xml element such as <name>Foo Bar</name> (note the space), isWhitespaceInElementContent will return false.
However it will return true for <name><name> or <name/>
so, that function can be used to determine if the element has a text content or not
up
0
JITR
17 years ago
To add to `permidion at yahoo dot com''s comment:

Quite true. According to DOM Level 3 Core, the `isWhitespaceInElementContent()' method indicates, whether the node contains `whitespace in element content' (or `element content whitespace' according to the newer spec), see [1].

Btw, it seems the `isWhitespaceInElementContent()' method was replaced with the `isElementContentWhitespace' attribute in the current W3C recommendation, see [2].

I have the feeling, though, it would be more precise with the word `only' added, like: `... indicates, whether the node contains *only* element content whitespace.' This would better correspond with the fact the result is false, when there are any non-whitespace characters present (in addition to the whitespace ones), as already noted.

[1] (please concatenate the following two lines)
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html
#core-Text3-isWhitespaceInElementContent
[2] (please concatenate the following two lines)
http://www.w3.org/TR/DOM-Level-3-Core/core.html
#Text3-isElementContentWhitespace
To Top