Creating an XML document from scratch – PB Docs 125

Creating an XML document from scratch

You can create an XML document in a script using the appropriate PBDOM_OBJECT
subclasses and methods. The following code uses the PBDOM_ELEMENT
and PBDOM_DOCUMENT classes and some of their methods to
create a simple XML document.

First, the objects are declared and instantiated:

The instantiated objects are assigned names. Note that the PBDOM_DOCUMENT
object pbdom_doc1 is not named:

The objects are arranged into a node tree using the AddContent method.
The AddContent method adds the referenced object
as a child node under the object from which AddContent is
invoked:

Use the NewDocument method to create a
new XML document. The parameter value supplied to the NewDocument method
becomes the name of the root element. This name is then accessed
from the PBDOM_DOCUMENT object pbdom_doc1 and
assigned to the PBDOM_ELEMENT object pbdom_elem_root using
the GetRootElement method:

The ELEMENT object pbdom_elem_1 and
all its child nodes are placed in the new XML document node tree
under the root element using the AddContent method.
Note that as the ancestor node pbdom_elem_1 is
placed in the node tree, all its child nodes move as well:

The XML document created looks like this:


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