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 
20 namespace Atom
21 {
22 
24 {
25  QString str;
26 
27  QDomElement el = parent.firstElementByTagNameNS(atom1Namespace(), tagname);
28 
29  bool isCDATA = el.firstChild().isCDATASection();
30 
31  QString type = el.attribute(QStringLiteral("type"), QStringLiteral("text"));
32 
33  if (type == QLatin1String("text")) {
34  str = parent.extractElementTextNS(atom1Namespace(), tagname).trimmed();
35  if (isCDATA) {
36  str = resolveEntities(str);
37  }
38 
39  str = escapeSpecialCharacters(str);
40  } else if (type == QLatin1String("html")) {
41  str = parent.extractElementTextNS(atom1Namespace(), tagname).trimmed();
42  } else if (type == QLatin1String("xhtml")) {
44  }
45 
46  return str;
47 }
48 
49 } // namespace Atom
50 } // namespace Syndication
51 
QString attribute(const QString &name, const QString &defValue) const const
A wrapper for XML elements.
QString childNodesAsXML() const
returns the child nodes of the wrapped element as XML.
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 trimmed() const const
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:23
QDomNode firstChild() const const
QString extractElementTextNS(const QString &namespaceURI, const QString &localName) const
extracts the text from a child element, respecting namespaces.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jan 27 2021 23:01:45 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.