Description
Returns the text data contained within a PBDOM_ATTRIBUTE object with surrounding spaces removed.
Syntax
pbdom_attribute_name.GetTextTrim()
Return value
String.
Examples
-
The GetTextTrim method is invoked for the PBDOM_ATTRIBUTE of the following element:
<abc ATTRIBUTE_1=" My Attribute ">
The GetTextNormalize method returns the following string:
My Attribute
Note that the whitespace characters surrounding the string are removed, but the whitespace characters within the string remain.
-
This example builds a PBDOM_DOCUMENT based on the following XML tree:
<abc My_Attr="   My	Attribute Value   "> <data>Data</data> </abc>
The My_Attr attribute contains an entity reference for a Tab character (	) and several entity references for the space character ( ). The message boxes in the following code show that GetText returns the complete text string of the attribute, whereas GetTextTrim returns the string with the surrounding whitespace characters removed. The Tab character between the words is not removed:
PBDOM_BUILDER pbdombuilder_new PBDOM_DOCUMENT pbdom_doc PBDOM_ATTRIBUTE pbdom_attr string strXML TRY strXML = "<abc My_Attr=~"   My	Attribute Value   ~"><data>Data</data></abc>" pbdombuilder_new = Create PBDOM_Builder pbdom_doc = pbdombuilder_new.BuildFromString (strXML) pbdom_attr = pbdom_doc.GetRootElement(). & GetAttribute("My_Attr") MessageBox ("pbdom_attr text", "[" & + "pbdom_attr.GetText() + "]") MessageBox ("pbdom_attr text normalize", & "[" + pbdom_attr.GetTextTrim() + "]") Destroy pbdombuilder_new Destroy pbdom_doc CATCH (PBDOM_Exception except) MessageBox ("Exception Occurred", except.Text) END TRY
Usage
Surrounding whitespace characters are removed from the returned text data. The GetTextTrim method returns an empty string if no text value exists for the PBDOM_ATTRIBUTE or if the text value contains only whitespace characters.
If this PBDOM_ATTRIBUTE contains any PBDOM_ENTITYREFERENCE objects, the name of the PBDOM_ENTITYREFERENCE object is returned as part of the trimmed string.
See also