GetText

Description

Obtains the text data that is contained within the current PBDOM_OBJECT.

Syntax

pbdom_object_name.GetText()

Argument

Description

pbdom_object_name

The name of the PBDOM_ OBJECT


Return value

String.

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

DOM Object Type

Return Value

PBDOM_ELEMENT

The concatenation of the text values of all the TEXT nodes contained within the PBDOM_ELEMENT.

If the PBDOM_ELEMENT definition is <abc>Root Element Data<data>ABC Data </data> now with extra info </abc>, then GetText returns "Root Element Data now with extra info ".

Extra Spaces

There are extra spaces between the word "Data" and "now" and again after the word "info". They are there because they originally exist in the text.

If the PBDOM_ELEMENT definition is: <abc>Root Element Data</abc>, then GetText returns "Root Element Data".

PBDOM_ATTRIBUTE

The text data contained within the PBDOM_ATTRIBUTE object.

If the element with an attribute is <abc ATTRIBUTE_1="My Attribute">, then GetText returns "My Attribute".

PBDOM_TEXT

The text data contained within the PBDOM_TEXT object itself.

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 GetText on the PBDOM_TEXT returns the string "MY TEXT"

PBDOM_CDATA

The string data that is contained within the CDATA section itself. 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 GetText on it returns the following string:

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

PBDOM_COMMENT

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

<!--This is some comment. -->

If there is a PBDOM_COMMENT to represent the above COMMENT, then calling GetText on it returns the following string:

This is some comment.

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, CDATA sections, or basic text. These include:

  • PBDOM_ELEMENT

  • PBDOM_ATTRIBUTE

  • PBDOM_TEXT

  • PBDOM_CDATA

  • PBDOM_COMMENT

The PBDOM_TEXT, PBDOM_CDATA, and PBDOM_COMMENT objects are special cases that cause the GetText method to return the text data that is intrinsically contained within the objects. A PBDOM_TEXT object is basically a DOM text node and therefore does not hold any child text nodes. A PBDOM_CDATA object represents a DOM CDATA object, and therefore does not hold any child DOM nodes. The same rule applies to a PBDOM_COMMENT object.

See also

GetTextNormalize

GetTextTrim