Syndication

atomtools.cpp
1 /*
2  This file is part of the syndication library
3  SPDX-FileCopyrightText: 2006 Frank Osterfeld <[email protected]>
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 
17 namespace Syndication
18 {
19 namespace Atom
20 {
22 {
23  QString str;
24 
25  QDomElement el = parent.firstElementByTagNameNS(atom1Namespace(), tagname);
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
QDomNode firstChild() const const
A wrapper for XML elements.
QString trimmed() const const
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...
bool isCDATASection() const const
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 childNodesAsXML() const
returns the child nodes of the wrapped element as XML.
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Tue Aug 9 2022 03:52:40 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.