WebSphere Message Broker, Version 8.0.0.7
Operating Systems: AIX, HP-Itanium, Linux, Solaris, Windows, z/OS
See information about the latest product version
See information about the latest product version
Creating new elements using a PHPCompute node
Use the PHPCompute node to create new elements in a message tree.
You can create new elements in a message tree in several ways:
- By using the MbsElement addElement method. By default this creates
an element as the last child of the current element. This method has
the following parameters:
- name
- value
- namespace
- type (optional)
- position (optional)
The position parameter can have one of the following values:- MB_FIRST_CHILD
- MB_LAST_CHILD
- MB_NEXT_SIBLING
- MB_PREVIOUS_SIBLING
- By using the path syntax. Elements on the left side of an assignment
expression are created (if they do not exist already) when they are
referenced in a path. For example, the following code navigates the
elements in the XMLNSC tree, creating them if necessary:
$output_assembly->XMLNSC->doc->folder->item = 'book';
- By using an MbsElement constructor. To create a PHP function that
creates and returns a subtree (part of a message), you can instantiate
an element, build extra elements (using either of the previous two
methods described), and return the result. You can then assign the
result into the output message. For example:
$output_assembly->XMLNSC->doc->part = create_subtree(); function create_subtree() { $element = new MbsElement(); $element->folder->item = 'some value'; return $element; }
You can also use the MbsElement addElementFromBitstream method to create an element tree from a string containing an unparsed bit stream. Use this method to defer until run time the decision about which parser to use.