mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-02 18:14:42 +02:00
feat(FeedParser): recursively parse rss modules (#4422)
Also stop excluding the media module fix #4415
This commit is contained in:
parent
952a2d99a3
commit
dd8bc077ed
2 changed files with 88 additions and 3 deletions
|
@ -174,7 +174,7 @@ final class FeedParser
|
|||
}
|
||||
|
||||
foreach ($namespaces as $namespaceName => $namespaceUrl) {
|
||||
if (in_array($namespaceName, ['', 'content', 'media'])) {
|
||||
if (in_array($namespaceName, ['', 'content'])) {
|
||||
continue;
|
||||
}
|
||||
$item[$namespaceName] = $this->parseModule($feedItem, $namespaceName, $namespaceUrl);
|
||||
|
@ -250,11 +250,17 @@ final class FeedParser
|
|||
|
||||
private function parseModule(\SimpleXMLElement $element, string $namespaceName, string $namespaceUrl): array
|
||||
{
|
||||
// Unfortunately this parses out only node values as string
|
||||
// TODO: parse attributes too
|
||||
|
||||
$result = [];
|
||||
$module = $element->children($namespaceUrl);
|
||||
foreach ($module as $name => $value) {
|
||||
// todo: add custom parsing if it's something other than a string
|
||||
$result[$name] = (string) $value;
|
||||
if (get_class($value) === 'SimpleXMLElement' && $value->count() !== 0) {
|
||||
$result[$name] = $this->parseModule($value, $namespaceName, $namespaceUrl);
|
||||
} else {
|
||||
$result[$name] = (string) $value;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue