GetTextTrim

Description

Gets the text data that is contained in the current PBDOM_OBJECT with all surrounding whitespace characters removed.

Syntax

pbdom_object_name.GetTextTrim()

Argument

Description

pbdom_object_name

The name of the PBDOM_OBJECT


Return value

String.

The trimmed text content of the current PBDOM_OBJECT, or an empty string if there is no text content or only whitespace characters.

Throws

EXCEPTION_PBDOM_OBJECT_INVALID_FOR_USE -- This PBDOM_OBJECT object is not associated with a derived PBDOM_OBJECT class object.

EXCEPTION_MEMORY_ALLOCATION_FAILURE -- Insufficient memory was encountered while executing this method.

Usage

This method returns meaningful data only if the PBDOM_OBJECT is of a type that can contain TEXT NODEs or CDATA Sections, or of a type that intrinsically contains basic text. These types are:

  • PBDOM_ELEMENT

  • PBDOM_ATTRIBUTE

  • PBDOM_TEXT

  • PBDOM_CDATA

  • PBDOM_COMMENT

The PBDOM_TEXT, PBDOM_CDATA, and PBDOM_COMMENT classes are special cases that cause the GetTextTrim method to return the intrinsic text data contained within their instances. A PBDOM_TEXT object represents a DOM text node, so it does not hold any child DOM Nodes. PBDOM_CDATA object is a representation of a DOM CDATA object and does not hold any child DOM Nodes, nor does PBDOM_COMMENT contain any child DOM Nodes.

The following table lists the return values based on the type of actual DOM Object contained within PBDOM_OBJECT:

DOM Object Type

Return Value

PBDOM_ELEMENT

The trimmed concatenation of the text values of all the TEXT Nodes and CDATA Sections contained within the PBDOM_ELEMENT. Surrounding whitespace characters are removed.

Suppose there is a PBDOM_ELEMENT defined as follows:

<abc>   Root Element Data<data>ABC Data </data> now with 
extra info   </abc>

GetTextTrim returns Root Element Data now with extra info.

Suppose there is a PBDOM_ELEMENT defined as follows:

<abc>  Root Element Data  </abc>

GetTextTrim returns Root Element Data.

Suppose there is a PBDOM_ELEMENT defined as follows:

<abc>Root Element Data <![CDATA[ with some cdata text]]></abc>

GetTextTrim returns Root Element Data with some cdata text.

PBDOM_ATTRIBUTE

The trimmed text data contained within the PBDOM_ATTRIBUTE object with surrounding whitespace characters removed.

Suppose there is an element with an attribute as follows:

<abc ATTRIBUTE_1="My     Attribute     ">

GetTextTrim returns:

My     Attribute

Note, however, that the spaces between "My" and "Attribute" are still present.

PBDOM_TEXT

The trimmed text data contained within the PBDOM_TEXT object itself with surrounding whitespace characters removed.

For example, suppose there is the following element:

<abc>  MY TEXT  </abc>

If there is a PBDOM_TEXT object to represent the text node "MY TEXT ", then calling GetTextTrim on the PBDOM_TEXT returns the string MY TEXT.

PBDOM_CDATA

The trimmed string data that is contained within the CDATA section itself with surrounding whitespace characters removed. For example, suppose there is the following CDATA:

<![CDATA[   They're saying "x < y" & that "z > y" so I 
guess   that means that z > x    ]]>

If there is a PBDOM_CDATA to represent the above CDATA section, then calling GetTextTrim on it returns the string:

They're saying " x < y " & that "z > y" so I 
guess   that means that z > x 

Note that the initial spaces before "They're" and the trailing space after the last "x" have been removed.

PBDOM_COMMENT

The trimmed string data that is contained within the COMMENT itself. For example, suppose there is the following COMMENT:

<!--   Comment   Here !   -->

Note the spaces before the word "Comment" and after the exclamation mark "!".

Calling GetTextTrim on the COMMENT returns the string Comment Here !


See also

GetText

GetTextNormalize