Try OpenEdge Now
skip to main content
Working with XML
Reading and Writing XML with the Document Object Model (DOM) : The ABL DOM interface : Representing a DOM node in ABL
 

Representing a DOM node in ABL

In essence, X-document represents the collection of nodes, their content of the nodes, and all the relationships between nodes.
The X-noderef object is an ABL object that is a reference to any node in a DOM tree (except a DOCUMENT node, which is the X-document). In ABL, you can create a handle to an X-noderef object, which in turn is a cursor pointing to a DOM node in a DOM tree (represented by an ABL X-document object).
The life cycle of an X-noderef object is similar to the X-document object's. For example:
DEFINE VARIABLE hNode AS HANDLE NO-UNDO.
CREATE X-NODEREF hNode.
. . .
DELETE OBJECT hNode.
There are many types of DOM nodes as identified by the SUBTYPE attribute of both the X-document and X-noderef objects. Some types of nodes may have child nodes of various types, and others are leaf nodes that cannot have anything below them in the document structure.
The ABL X-noderef object can be one of the following DOM node types, as indicated by the SUBTYPE attribute:
*ATTRIBUTE
*CDATA-SECTION
*COMMENT
*DOCUMENT-FRAGMENT
*ELEMENT
*ENTITY-REFERENCE
*PROCESSING-INSTRUCTION
*TEXT
The default subtype is ELEMENT.
The following table shows X-noderef object SUBTYPE values, and how the NAME and NODE-VALUE attributes are different based on SUBTYPE.
Table 1. X-noderef SUBTYPE, NAME, and NODE-VALUE attributes
SUBTYPE attribute
NAME attribute
NODE-VALUE attribute
ATTRIBUTE
The name of the attribute. Primarily used with namespaces
The value of the attribute
DOCUMENT-FRAGMENT
Ignored
Content of the fragment
ELEMENT
XML tag name, including namespace information
Null
ENTITY-REFERENCE
The name of the entity referenced without the leading ampersand and trailing semicolon
Null
TEXT
Ignored
Content of the text node
CDATA-SECTION
Ignored
Content of the CDATA-SECTION
COMMENT
Ignored
Content of the COMMENT
PROCESSING-INSTRUCTION
The target, which is the first XML token following the <? markup
Content excluding the target