/** * Returns all child elements of the given name. Special handling for the following names is implemented: * - 'paramaters' returns all direct 'parameters' OR all 'parameters/parameter' child nodes * - 'formatters' returns all direct 'formatters' OR all 'formatters/formatter' child nodes * * @param string $name name of child element * * @return \DOMNodeList of all child elements with the given name in the default namespace */ public function getChildren($name) { $query = ''; $singular_name = null; // special nodes of environaut config files where the surrounding plural node // may be omitted and the singular nodes be used directly (for less verbose xml) if (in_array($name, array('parameters', 'formatters'))) { if ($name === 'parameters') { $singular_name = 'parameter'; } elseif ($name === 'formatters') { $singular_name = 'formatter'; } $query = 'child::*[local-name() = "%2$s" and namespace-uri() = "%3$s"] | ' . 'child::*[local-name() = "%1$s" and namespace-uri() = "%3$s"]/*' . '[local-name() = "%2$s" and namespace-uri() = "%3$s"]'; } else { $query = 'child::*[local-name() = "%1$s" and namespace-uri() = "%3$s"]'; } $nodes = $this->ownerDocument->getXpath()->query(sprintf($query, $name, $singular_name, $this->ownerDocument->getDefaultNamespaceUri()), $this); return $nodes; }