You are here

function globallink_insert_child_element in GlobalLink Connect for Drupal 7.5

Same name and namespace in other branches
  1. 7.7 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.

10 calls to globallink_insert_child_element()
globallink_block_get_xml in globallink_block/globallink_block.inc
Gets XML data from specific block.
globallink_entity_generate_xml_document in globallink_entity/globallink_entity.inc
Generates XML document for entity.
globallink_entity_traverse_fields_and_field_collections in globallink_entity/globallink_entity.inc
Traverses entity fields and field collections.
globallink_fieldable_panels_pane_get_xml in globallink_fieldable_panels/globallink_fieldable_panels.inc
Gets XML data from specific fieldable panel.
globallink_generate_xml_document in ./globallink_node.inc
Builds XML document with translation data.

... See full list

File

./globallink.inc, line 89
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);
  }
}