public function GenericOpmlParser::parse in Feeds 8.3
Parses the OPML file.
@todo Document the return value.
Parameters
bool $normalize_case: (optional) True to convert all attributes to lowercase. False, to leave them as is. Defaults to false.
Return value
array A structured array.
File
- src/
Component/ GenericOpmlParser.php, line 49
Class
- GenericOpmlParser
- Parses a generic OPML string into an array.
Namespace
Drupal\feeds\ComponentCode
public function parse($normalize_case = FALSE) {
$this->normalizeCase = $normalize_case;
// Title is a required field, let parsers assume its existence.
$return = [
'head' => [
'#title' => '',
],
];
foreach ($this->xpath
->query('/opml/head/*') as $element) {
if ($this->normalizeCase) {
$return['head']['#' . strtolower($element->nodeName)] = $element->nodeValue;
}
else {
$return['head']['#' . $element->nodeName] = $element->nodeValue;
}
}
if (isset($return['head']['#expansionState'])) {
$return['head']['#expansionState'] = array_filter(explode(',', $return['head']['#expansionState']));
}
$return['outlines'] = [];
if ($content = $this->xpath
->evaluate('/opml/body', $this->xpath->document)
->item(0)) {
$return['outlines'] = $this
->getOutlines($content);
}
return $return;
}