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

MbsElement

The MbsElement class represents a single parsed element in a message (or other logical tree).

The MbsElement class provides the API methods shown in the following table (parameters in square brackets are optional):

Method Description
Constructor() Instantiates a new MbsElement object.
object getValue() Returns the value of the current element.
void setValue(object $value) Sets the value of the current element.
int getType() Returns the specific type of the current element. For a full list of type values, see PHP constants for type values.
void setType(int $type) Sets the specific type of the current element. For a full list of type values, see PHP constants for type values.
object xpath(string $expression [, array $namespace]) Evaluates the XPath expression with the current element as the context node. It returns the result as either a string, double, boolean, or a nodeset as an array of MbsElement objects. The optional namespace parameter is an associative array with namespace prefixes as the keys and namespace URIs as the values.
string getName() Returns the name of the current element.
void setName(string $name) Sets the name of the current element.
string getNamespace() Returns the namespace URI of the current element.
void setNamespace($namespace) Sets the namespace URI of the current element.
MbsElement getParent() Returns the parent of the current element.
MbsElement getChild(string $name [, int $occurrence]) Returns the first child of the current element whose name is given by the first parameter. The nth occurrence of that child can be returned by specifying the second optional parameter.
array getChildren([string $namespace]) Returns all the child elements n of the current element as an array of MbsElements. If the namespace parameter is specified, the array contains only the child elements with that namespace URI.
MbsElement getFirstChild() Returns the first child of the current element.
MbsElement getLastChild() Returns the last child of the current element.
MbsElement getNextSibling() Returns the next sibling of the current element.
MbsElement getPreviousSibling() Returns the previous sibling of the current element.
MbsElement getAttribute(string $name) Returns the attribute of the current element given by the name parameter.
MbsElement addAttribute(string $name, object $value [, string $namespace]) Adds an attribute to the current element.
MbsElement addElement(string $name, object $value [, string $namespace [, int $type [, int $position]]]) Creates an element as last child (by default) of the current element. The optional type parameter is the parser-specific type of the new node (which defaults to XML element type for XML parsers). The optional position parameter can be one of the following values:
  • MB_FIRST_CHILD
  • MB_LAST_CHILD
  • MB_NEXT_SIBLING
  • MB_PREVIOUS_SIBLING
MbsElement detach() Detaches the current element from the tree.
void detachAllChildren() Detaches all child elements of the current element.
string asBitstream([array $options]) Serializes the element tree to produce a bit stream. When using the MRM parser (and other parsers), the options array must be populated with the following key/value pairs:
array ('set' => '<MessageSet>', 
'type' => '<MessageType>',
'format' => '<MessageFormat>',
'encoding' => '<encoding>',
'ccsid' => '<ccsid>')
void addElementFromBitstream(string $bitstream [, array $options]) Creates an element tree from the supplied bit stream. Without options supplied, the bit stream is parsed by using the parser of the current element and attached as its last child (no domain element is created in this case). If options is supplied, it must contain the key/value pair 'domain' => '<parserDomain>' plus any of the additional options for the MRM parser (see asBitstream()). In this case, a parser element is created at the head of the new subtree and attached as the last child of the current element.
You can create elements in PHP to build subtrees. The following example shows a PHP function that generates and returns part of an output tree:
function transformItem($input) {
      $item = new MbsElement;
      $item->Desc = $input->Description;
      $item->Cost = $input->Price->getValue() * 1.6;
      $item->Qty = $input->Quantity;

      return $item;
   }
You can copy this subtree into an output message by using the following code:
$output_assembly->XMLNSC->doc->item = transformItem($input_sub_tree);
where $input_sub_tree is a reference to a part of the input message.
Notices | Trademarks | Downloads | Library | Support | Feedback

Copyright IBM Corporation 1999, 2016Copyright IBM Corporation 1999, 2016.

        
        Last updated:
        
        Last updated: 2016-05-23 14:46:34


Reference topicReference topic | Version 8.0.0.7 | ac69022_