返回介绍

QXmlReader Class

发布于 2019-10-04 15:04:18 字数 8227 浏览 997 评论 0 收藏 0

The QXmlReader class provides an interface for XML readers (i.e. parsers). More...

#include <qxml.h>

Inherited by QXmlSimpleReader.

List of all member functions.

Public Members

  • virtual bool feature ( constQString&name, bool*ok = 0 ) const = 0
  • virtual void setFeature ( constQString&name, boolvalue ) = 0
  • virtual bool hasFeature ( constQString&name ) const = 0
  • virtual void * property ( constQString&name, bool*ok = 0 ) const = 0
  • virtual void setProperty ( constQString&name, void*value ) = 0
  • virtual bool hasProperty ( constQString&name ) const = 0
  • virtual void setEntityResolver ( QXmlEntityResolver*handler ) = 0
  • virtual QXmlEntityResolver * entityResolver () const = 0
  • virtual void setDTDHandler ( QXmlDTDHandler*handler ) = 0
  • virtual QXmlDTDHandler * DTDHandler () const = 0
  • virtual void setContentHandler ( QXmlContentHandler*handler ) = 0
  • virtual QXmlContentHandler * contentHandler () const = 0
  • virtual void setErrorHandler ( QXmlErrorHandler*handler ) = 0
  • virtual QXmlErrorHandler * errorHandler () const = 0
  • virtual void setLexicalHandler ( QXmlLexicalHandler*handler ) = 0
  • virtual QXmlLexicalHandler * lexicalHandler () const = 0
  • virtual void setDeclHandler ( QXmlDeclHandler*handler ) = 0
  • virtual QXmlDeclHandler * declHandler () const = 0
  • virtual bool parse ( constQXmlInputSource&input ) = 0 (obsolete)
  • virtual bool parse ( constQXmlInputSource*input ) = 0

Detailed Description

The QXmlReader class provides an interface for XML readers (i.e. parsers).

This abstract class provides an interface for all XML readers in Qt. At the moment there is only one implementation of a reader included in the XML module of Qt (QXmlSimpleReader). In future releases there might be more readers with different properties available (e.g. a validating parser).

The design of the XML classes follows the SAX2 java interface. It was adapted to fit the Qt naming conventions; so it should be very easy for anybody who has worked with SAX2 to get started with the Qt XML classes.

All readers use the class QXmlInputSource to read the input document. Since you are normally interested in particular content in the XML document, the reader reports the content through special handler classes (QXmlDTDHandler, QXmlDeclHandler, QXmlContentHandler, QXmlEntityResolver, QXmlErrorHandler and QXmlLexicalHandler), which you must subclass, if you want to process the contents..

Since the handler classes describe only interfaces you must implement all functions; there is a class (QXmlDefaultHandler) to make this easier; it implements a default behaviour (do nothing) for all functions.

Features and properties of the reader can be set with setFeature() and setProperty respectively. You can set the reader to use your own subclasses with setEntityResolver(), setDTDHandler(), setContentHandler(), setErrorHandler(), setLexicalHandler() and setDeclHandler(). The parse itself is started with a call to parse().

For getting started see also the tiny SAX2 parser walkthrough.

See also QXmlSimpleReader and XML.


Member Function Documentation

QXmlDTDHandler* QXmlReader::DTDHandler () const [pure virtual]

Returns the DTD handler or 0 if none was set.

See also setDTDHandler().

QXmlContentHandler* QXmlReader::contentHandler () const [pure virtual]

Returns the content handler or 0 if none was set.

See also setContentHandler().

QXmlDeclHandler* QXmlReader::declHandler () const [pure virtual]

Returns the declaration handler or 0 if none was set.

See also setDeclHandler().

QXmlEntityResolver* QXmlReader::entityResolver () const [pure virtual]

Returns the entity resolver or 0 if none was set.

See also setEntityResolver().

QXmlErrorHandler* QXmlReader::errorHandler () const [pure virtual]

Returns the error handler or 0 if none was set.

See also setErrorHandler().

bool QXmlReader::feature ( constQString&name, bool*ok = 0 ) const [pure virtual]

If the reader has the feature called name, the feature's value is returned. If no such feature exists the return value is undefined.

If ok is not 0, then *ok is set to TRUE if the reader has the feature called name; otherwise *ok is set to FALSE.

See also setFeature() and hasFeature().

bool QXmlReader::hasFeature ( constQString&name ) const [pure virtual]

Returns TRUE if the reader has the feature name; otherwise returns FALSE.

See also feature() and setFeature().

bool QXmlReader::hasProperty ( constQString&name ) const [pure virtual]

Returns TRUE if the reader has the property name; otherwise returns FALSE.

See also property() and setProperty().

QXmlLexicalHandler* QXmlReader::lexicalHandler () const [pure virtual]

Returns the lexical handler or 0 if none was set.

See also setLexicalHandler().

bool QXmlReader::parse ( constQXmlInputSource*input ) [pure virtual]

Reads an XML document from input and parses it. Returns TRUE if the parsing was successful; otherwise returns FALSE.

Example: xml/tagreader/tagreader.cpp.

bool QXmlReader::parse ( constQXmlInputSource&input ) [pure virtual]

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

void * QXmlReader::property ( constQString&name, bool*ok = 0 ) const [pure virtual]

If the reader has the property name, this function returns the value of the property and sets *ok to TRUE; otherwise *ok is set to FALSE.

See also setProperty() and hasProperty().

void QXmlReader::setContentHandler ( QXmlContentHandler*handler ) [pure virtual]

Sets the content handler to handler.

See also contentHandler().

Example: xml/tagreader/tagreader.cpp.

void QXmlReader::setDTDHandler ( QXmlDTDHandler*handler ) [pure virtual]

Sets the DTD handler to handler.

See also DTDHandler().

void QXmlReader::setDeclHandler ( QXmlDeclHandler*handler ) [pure virtual]

Sets the declaration handler to handler.

See also declHandler().

void QXmlReader::setEntityResolver ( QXmlEntityResolver*handler ) [pure virtual]

Sets the entity resolver to handler.

See also entityResolver().

void QXmlReader::setErrorHandler ( QXmlErrorHandler*handler ) [pure virtual]

Sets the error handler to handler. Clears the error handler if handler is 0.

See also errorHandler().

void QXmlReader::setFeature ( constQString&name, boolvalue ) [pure virtual]

Sets the feature called name to the given value. If the reader doesn't have the feature nothing happens.

See also feature() and hasFeature().

void QXmlReader::setLexicalHandler ( QXmlLexicalHandler*handler ) [pure virtual]

Sets the lexical handler to handler.

See also lexicalHandler().

void QXmlReader::setProperty ( constQString&name, void*value ) [pure virtual]

Sets the property name to value. If the reader doesn't have the property nothing happens.

See also property() and hasProperty().

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文