File indexing completed on 2024-12-01 03:45:44
0001 /* 0002 This file is part of the syndication library 0003 SPDX-FileCopyrightText: 2005 Frank Osterfeld <osterfeld@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include "tools.h" 0009 #include <constants.h> 0010 #include <elementwrapper.h> 0011 0012 #include <QDomElement> 0013 #include <QList> 0014 #include <QString> 0015 0016 namespace Syndication 0017 { 0018 namespace RSS2 0019 { 0020 //@cond PRIVATE 0021 QString extractContent(const ElementWrapper &wrapper) 0022 { 0023 if (wrapper.isNull()) { 0024 return QString(); 0025 } 0026 0027 QList<QDomElement> list = wrapper.elementsByTagNameNS(contentNameSpace(), QStringLiteral("encoded")); 0028 0029 if (!list.isEmpty()) { 0030 return list.first().text().trimmed(); 0031 } 0032 0033 list = wrapper.elementsByTagNameNS(xhtmlNamespace(), QStringLiteral("body")); 0034 0035 if (!list.isEmpty()) { 0036 return ElementWrapper::childNodesAsXML(list.first()).trimmed(); 0037 } 0038 0039 list = wrapper.elementsByTagNameNS(xhtmlNamespace(), QStringLiteral("div")); 0040 0041 if (!list.isEmpty()) { 0042 return ElementWrapper::childNodesAsXML(list.first()).trimmed(); 0043 } 0044 0045 return QString(); 0046 } 0047 //@endcond 0048 0049 } // namespace RSS2 0050 } // namespace Syndication