Accessing node data – PB Docs 125

Accessing node data

An XML document can be read by accessing the elements of its
node tree using the appropriate PBDOM_OBJECT subclasses
and methods. The following code uses an array, the PBDOM_OBJECT,
and its descendant class PBDOM_DOCUMENT, and the GetContent and GetRootElement methods
of the PBDOM_DOCUMENT class to access node data on an XML
document.

A PBDOM_DOCUMENT object named pbdom_doc contains
the following XML document:

The following code declares an array to hold the elements
returned from the GetContent method, which reads
the PBDOM_DOCUMENT object named pbdom_doc:

The pbdom_obj_array array
now contains one value representing the root element of pbdom_doc: <Root>.

To access the other nodes in pbdom_doc,
the GetRootElement method is used with the GetContent method.

The pbdom_obj_array array
now contains three values corresponding to the three child nodes
of the root element of pbdom_doc: <Element_1>, <Element_2>,
and <Element_3>.

PBDOM provides other methods for accessing data, including InsertContent, AddContent, RemoveContent,
and SetContent.

Changing node content with arrays

You can use the AddContent method to change
node content:

This line of code changes the node tree as follows:

note.png Arrays and object references

When you use a method such as the GetContent method
of the PBDOM_DOCUMENT class to return an array of PBDOM_OBJECT references,
the references are to instantiated PBDOM objects. If you modify any
of these objects through its array item, the changes are permanent
and are reflected in any other arrays that hold the same object
reference.


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x