1 | /* |
---|---|
2 | This file is part of the syndication library |
3 | SPDX-FileCopyrightText: 2005 Frank Osterfeld <osterfeld@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #include "tools.h" |
9 | #include <constants.h> |
10 | #include <elementwrapper.h> |
11 | |
12 | #include <QDomElement> |
13 | #include <QList> |
14 | #include <QString> |
15 | |
16 | namespace Syndication |
17 | { |
18 | namespace RSS2 |
19 | { |
20 | //@cond PRIVATE |
21 | QString extractContent(const ElementWrapper &wrapper) |
22 | { |
23 | if (wrapper.isNull()) { |
24 | return QString(); |
25 | } |
26 | |
27 | QList<QDomElement> list = wrapper.elementsByTagNameNS(nsURI: contentNameSpace(), QStringLiteral("encoded")); |
28 | |
29 | if (!list.isEmpty()) { |
30 | return list.first().text().trimmed(); |
31 | } |
32 | |
33 | list = wrapper.elementsByTagNameNS(nsURI: xhtmlNamespace(), QStringLiteral("body")); |
34 | |
35 | if (!list.isEmpty()) { |
36 | return ElementWrapper::childNodesAsXML(parent: list.first()).trimmed(); |
37 | } |
38 | |
39 | list = wrapper.elementsByTagNameNS(nsURI: xhtmlNamespace(), QStringLiteral("div")); |
40 | |
41 | if (!list.isEmpty()) { |
42 | return ElementWrapper::childNodesAsXML(parent: list.first()).trimmed(); |
43 | } |
44 | |
45 | return QString(); |
46 | } |
47 | //@endcond |
48 | |
49 | } // namespace RSS2 |
50 | } // namespace Syndication |
51 |