From c524e54d2da4af0c617021b4e9089a8803f78965 Mon Sep 17 00:00:00 2001 From: pictuga Date: Mon, 17 Jan 2022 13:59:58 +0000 Subject: [PATCH] feeds: support some exotic xpath rules returning a single string --- morss/feeds.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/morss/feeds.py b/morss/feeds.py index b3c13c9..0389a1c 100644 --- a/morss/feeds.py +++ b/morss/feeds.py @@ -359,7 +359,13 @@ class ParserXML(ParserBase): def rule_search_all(self, rule): try: - return self.root.xpath(rule, namespaces=self.NSMAP) + match = self.root.xpath(rule, namespaces=self.NSMAP) + if isinstance(match, str): + # some xpath rules return a single string instead of an array (e.g. concatenate() ) + return [match,] + + else: + return match except etree.XPathEvalError: return []