Community articleGetLocalName function
Added by IBM contributorIBM on May 2, 2012
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

No abstract provided.


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">
         <bgcolor>120, 120, 120</bgcolor>

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">

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


   Function GetLocalName() As String


There are no parameters for this function.


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


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))
         Set TempNode = TempNode.GetNext
      ' 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