Syndication

atomtools.cpp
1/*
2 This file is part of the syndication library
3 SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "constants.h"
9#include "tools.h"
10
11#include <syndication/elementwrapper.h>
12#include <syndication/tools.h>
13
14#include <QDomElement>
15#include <QString>
16
17namespace Syndication
18{
19namespace Atom
20{
22{
23 QString str;
24
26
27 bool isCDATA = el.firstChild().isCDATASection();
28
29 QString type = el.attribute(QStringLiteral("type"), QStringLiteral("text"));
30
31 if (type == QLatin1String("text")) {
32 str = parent.extractElementTextNS(atom1Namespace(), tagname).trimmed();
33 if (isCDATA) {
34 str = resolveEntities(str);
35 }
36
37 str = escapeSpecialCharacters(str);
38 } else if (type == QLatin1String("html")) {
39 str = parent.extractElementTextNS(atom1Namespace(), tagname).trimmed();
40 } else if (type == QLatin1String("xhtml")) {
42 }
43
44 return str;
45}
46
47} // namespace Atom
48} // namespace Syndication
A wrapper for XML elements.
QDomElement firstElementByTagNameNS(const QString &nsURI, const QString &tagName) const
searches the direct children of the wrapped element for an element with a given namespace and tag nam...
QString childNodesAsXML() const
returns the child nodes of the wrapped element as XML.
QString extractElementTextNS(const QString &namespaceURI, const QString &localName) const
extracts the text from a child element, respecting namespaces.
QString atom1Namespace()
namespace used by Atom 1.0 elements
QString extractAtomText(const Syndication::ElementWrapper &parent, const QString &tagname)
extracts the content of an atomTextConstruct.
Definition atomtools.cpp:21
QString attribute(const QString &name, const QString &defValue) const const
QDomNode firstChild() const const
bool isCDATASection() const const
QString trimmed() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:02:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.