Moving to an Element

Once a file has been opened and parsed, you can navigate the file in many different ways. In XML, you must move to an element of interest before you can retrieve its data. Listed below are several op-codes that you can call from the C$XML routine for this purpose. Be sure to specify the handle of the element or parser to move to, as in:

call "C$XML" using CXML-GET-FIRST-CHILD 
                   parser-handle.
Op-code Description
CXML-GET-FIRST-CHILD Moves to the first child of an element
CXML-GET-NEXT-SIBLING     Moves to the subsequent sibling of an element
CXML-GET-PREV-SIBLING Moves to the previous sibling; one way to move backward in a file
CXML-GET-PARENT Moves to the parent; another way to move backward in a file

More advanced options include:

These options allow you to navigate to a specific child or sibling in an element rather than simply the next or previous one. Details are provided in General Syntax and Library List.

Note that these op-codes do not retrieve element data. They simply move to the element and return the element handle. Once you have the handle to the element of interest, you can call CXML-GET-DATA to retrieve the data associated with the element.

Note: If desired, you can retrieve element attributes and comments as well. See Retrieving attributes and Retrieving comments, for more information.