You are here

protected function MigrateItemsXML::getElementValue in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 plugins/sources/xml.inc \MigrateItemsXML::getElementValue()

Get an element from the itemXML based on an xpath.

Parameters

SimpleXMLElement $item_xml: Element from we get the required value

string $xpath: xpath used to locate the value

Return value

string Extracted value

1 call to MigrateItemsXML::getElementValue()
MigrateItemsXML::getItemID in plugins/sources/xml.inc
Get the item ID from the itemXML based on itemIDXpath.

File

plugins/sources/xml.inc, line 786
Support for migration from XML sources.

Class

MigrateItemsXML
Implementation of MigrateItems, for providing a list of IDs and for retrieving a parsed XML document given an ID from this list.

Code

protected function getElementValue($item_xml, $xpath) {
  $value = NULL;
  if ($item_xml
    ->asXML()) {
    $result = $item_xml
      ->xpath($xpath);
    if ($result) {
      $value = (string) $result[0];
    }
  }
  return $value;
}