Community articleGetLocalName function
Added by IBM contributorIBM on August 15, 2011
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

No abstract provided.



Description

This function returns the local name of a given node. The local name is determined by the XML tag that represents that node. For example, examine the following XML fragment:
   <page sid="PAGE1">
      <global sid="global"></global>
      <field sid="testField">
         <value>Hello</value>
         <bgcolor>120, 120, 120</bgcolor>
      </field>
   </page>

In this sample, the name of the page node is "page", the name of the field node is "field", the name of the value node is "value", and the name of the bgcolor node is "bgcolor".
Note that the local name does not include any namespace prefix that might exist. For example, you might have a custom option in a different namespace as shown:
   <field sid="testField">
      <custom:my_option>value</custom:my_option>
   </field>

In this case, the local name of the custom option is returned without the prefix, resulting in "my_option".

Function

   Function GetLocalName() As String


Parameters

There are no parameters for this function.

Returns

The name of the node or throws an exception if an error occurs.

Example

The following function uses GetChildren and GetNext to walk through the entire form recursively. While walking through the form, the function uses IsXFDL and GetLocalName to test each node in the form and determine whether it is an XFDL label node. If so, the function uses SetLiteralByRefEx to set the label's background color to green.
   Sub ChangeLabelColor(Node)
 
      Dim TempNode, BGColorNode  ' objects
 
      ' Use recursion to step through each node in the form
 
      Set TempNode = Node.GetChildren
 
      Do While (Not(TempNode Is Nothing))
         ChangeLabelColor(TempNode)
         Set TempNode = TempNode.GetNext
      Loop
 
      ' If the node is a label in the XFDL namespace, locate the background
      ' color child node and change its value to green.
 
      If ((Node.IsXFDL) And (Node.GetLocalName = "label")) Then
         Node.SetLiteralByRefEx vbNullString, "bgcolor [0]", 0, _
            vbNullString, Nothing, "green"
      End If
 
   End Sub


Parent topic:
FormNodeP functions