You are here

function globallink_insert_child_element in GlobalLink Connect for Drupal 7.7

Same name and namespace in other branches
  1. 7.5 globallink.inc \globallink_insert_child_element()
  2. 7.6 globallink.inc \globallink_insert_child_element()

Inserts child element into DOM.

Parameters

array $dom: Array representation of the DOM.

array $root: The root of the DOM.

string $elem_name: The desired name of the element.

string $elem_value: The desired value of the element.

array $attributes: Array of desired attributes for the element. Defaults to NULL.

17 calls to globallink_insert_child_element()
globallink_beans_get_xml in globallink_beans/globallink_beans.inc
Gets XML data from specific bean.
globallink_beans_traverse_fields_and_field_collections in globallink_beans/globallink_beans.inc
Recursively adds fields and field collections to translation XML document.
globallink_block_get_xml in globallink_block/globallink_block.inc
Gets XML data from specific block.
globallink_commerce_get_xml in globallink_commerce/globallink_commerce.inc
Gets XML data from specific commerce product.
globallink_commerce_traverse_fields_and_field_collections in globallink_commerce/globallink_commerce.inc

... See full list

File

./globallink.inc, line 93
Miscellaneous GlobalLink functions for node translations (non-entity).

Code

function globallink_insert_child_element($dom, $root, $elem_name, $elem_value, $attributes = NULL) {
  if ($elem_name && $elem_value) {
    $item = $dom
      ->createElement($elem_name);
    if (isset($attributes) && is_array($attributes)) {
      foreach ($attributes as $key => $value) {
        $item
          ->setAttribute($key, $value);
      }
    }
    $text = $dom
      ->createTextNode($elem_value);
    $item
      ->appendChild($text);
    $root
      ->appendChild($item);
  }
}