GetText

Description

Returns the text value of the PBDOM_ATTRIBUTE object.

Syntax

pbdom_attribute_name.GetText()

Argument

Description

pbdom_attribute_name

The name of the PBDOM_ ATTRIBUTE


Return value

String.

Throws

EXCEPTION_USE_OF_UNNAMED_PBDOM_OBJECT -- If this PBDOM_ATTRIBUTE does not have or has not been assigned a user-defined name.

Examples

  1. The GetText method is invoked for the attribute in the following element:

    <abc ATTRIBUTE_1="My Attribute">

    The GetText method returns the following string:

    My Attribute
  2. This example sets an attribute called my_attr for the root element with text value text part. A PBDOM_ENTITYREFERENCE with the name ent_ref and a PBDOM_TEXT with the text value text part again are then added as part of the contents of my_attr. A call to GetText on my_attr returns the following text:

    "text part &ent_ref; text part again."

    The entity reference &ent_ref; is not expanded. If an entity reference is included in an input XML document that is parsed, then the entity reference is expanded before the XML document is transformed into a DOM tree in memory.

    PBDOM_DOCUMENT          pbdom_doc
    PBDOM_ATTRIBUTE         pbdom_attr
    PBDOM_ENTITYREFERENCE   pbdom_entref
    PBDOM_TEXT              pbdom_txt
    
    try
      pbdom_doc = Create PBDOM_DOCUMENT
      pbdom_entref = Create PBDOM_ENTITYREFERENCE
      pbdom_txt = Create PBDOM_TEXT
    
      // Create a new document object.
      pbdom_doc.NewDocument ("root")
    
      // Set the text of "pbdom_txt".
      pbdom_txt.SetText (" text part again.")
    
      // Add an attribute "my_attr" to the root element.
      pbdom_doc.GetRootElement().SetAttribute("my_attr", &
         "text part ")
    
      // Set the name of the PBDOM_ENTITYREFERENCE.  
      pbdom_entref.SetName ("ent_ref")
    
      // Append the entity reference to the root 
      // element's "my_attr" attribute.
      pbdom_doc.GetRootElement(). &
         GetAttribute("my_attr").AddContent(pbdom_entref)
    
      // Append a new text node to the "my_attr" attribute.
      pbdom_doc.GetRootElement() . &
          GetAttribute("my_attr").AddContent (pbdom_txt)
      
      // Now test the text contents of "my_attr  "
      if pbdom_doc.GetRootElement(). &
         GetAttribute("my_attr").GetText() = &
         "text part &ent_ref; text part again." then
        MessageBox ("Pass", &
           "GetText() on my_attr is correct.")
    
    else
        MessageBox ("Fail", &
            "GetText() on my_attr is incorrect.")
      end if
    
    catch (pbdom_exception pbdom_e)
      MessageBox ("PBDOM_EXCEPTION", pbdom_e.GetMessage())
    end try

Usage

This method returns the actual textual value of this PBDOM_ATTRIBUTE, including all text within the quotation marks. If there are any PBDOM_ENTITYREFERENCE objects included within the PBDOM_ATTRIBUTE, the PBDOM_ENTITYREFERENCE object's name is returned together with the leading ampersand ('&') character plus the terminating semicolon character (';').

See also

GetTextNormalize

GetTextTrim

SetText