You are here

public static function XmlHelper::parseElements in Helper 7

Convert a string of XML to an associative array.

The converse of format_xml_elements().

Parameters

string|SimpleXmlElement $data: The XML data to parse.

array $options:

Return value

array|bool An array representing the XML data, or FALSE if there was a failure.

1 call to XmlHelper::parseElements()
XmlHelperTestCase::assertParseElements in tests/XmlHelperTestCase.test

File

lib/XmlHelper.php, line 17

Class

XmlHelper

Code

public static function parseElements($data, array $options = array()) {
  $xml = static::normalizeDataToSimpleXml($data);
  $options += array(
    'simplify' => TRUE,
    'namespaces' => $xml
      ->getNamespaces(TRUE),
  );
  $results = array(
    static::parseElement($xml, $options),
  );
  if (!empty($options['simplify'])) {
    static::simplifyElements($results);
  }
  return $results;
}