Example 2: Displaying a DOM tree recursively

The following example displays a DOM tree content recursively:

FUNCTION displayDomNode(n,e)
  DEFINE n om.DomNode
  DEFINE e, i, s INTEGER

  LET s = e*2
  DISPLAY s SPACES || "Tag: " || n.getTagName()

  DISPLAY s SPACES || "Attributes:"
  FOR i=1 TO n.getAttributesCount()
     DISPLAY s SPACES || "  " || n.getAttributeName(i) || 
                     "=[" || n.getAttributeValue(i) ||"]"
  END FOR
  LET n = n.getFirstChild()

  DISPLAY s SPACES || "Child Nodes:"
  WHILE n IS NOT NULL
    CALL displayDomNode(n,e+1)
    LET n = n.getNext()
  END WHILE

END FUNCTION