Syndication

rss2/parser.cpp
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 "parser.h"
9#include "document.h"
10
11#include <documentsource.h>
12
13#include <QDomDocument>
14#include <QString>
15
16namespace Syndication
17{
18namespace RSS2
19{
20class SYNDICATION_NO_EXPORT Parser::ParserPrivate
21{
22};
23
25{
26 QDomDocument doc = source.asDomDocument();
27 if (doc.isNull()) {
28 return false;
29 }
30
31 QDomNode root = doc.namedItem(QStringLiteral("rss")).toElement();
32
33 return !root.isNull();
34}
35
36Syndication::SpecificDocumentPtr Parser::parse(const DocumentSource &source) const
37{
39}
40
42{
43 return QStringLiteral("rss2");
44}
45
47 : d(nullptr)
48{
49 Q_UNUSED(d) // silence -Wunused-private-field
50}
51
52Parser::Parser(const Parser &other)
53 : AbstractParser(other)
54 , d(nullptr)
55{
56}
57Parser::~Parser() = default;
58
59Parser &Parser::operator=(const Parser & /*other*/)
60{
61 return *this;
62}
63
64} // namespace RSS2
65} // namespace Syndication
Interface for all parsers.
Represents the source of a syndication document, as read from the downloaded file.
QDomDocument asDomDocument() const
Returns the feed source as DOM document.
document implementation, representing an RSS feed from the 0.91-0.94/2.0 family.
static Document fromXML(const QDomDocument &document)
Parses an RSS2 document from an XML document.
Parser implementation for the RSS 0.9x/2.0 format family.
Definition rss2/parser.h:30
Parser()
default constructor
Syndication::SpecificDocumentPtr parse(const DocumentSource &source) const override
creates an RSS2 wrapper for a document source.
QString format() const override
returns the format string of this parser implementation, which is "rss2".
~Parser() override
destructor
bool accept(const DocumentSource &source) const override
checks whether a document source looks like an RSS0.9x/2.0 document
bool isNull() const const
QDomNode namedItem(const QString &name) const const
QDomElement toElement() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:18 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.