QXmlStreamReader 類

QXmlStreamReader 類為憑藉簡單流化 API 讀取格式良好的 XML 提供快速剖析器。 更多...

頭: #include <QXmlStreamReader>
qmake: QT += core
Since: Qt 4.3

該類在 Qt 4.3 引入。

注意: 此類的所有函數 可重入 .

公共類型

enum Error { NoError, CustomError, NotWellFormedError, PrematureEndOfDocumentError, UnexpectedElementError }
enum ReadElementTextBehaviour { ErrorOnUnexpectedElement, IncludeChildElements, SkipChildElements }
enum TokenType { NoToken, Invalid, StartDocument, EndDocument, StartElement, …, ProcessingInstruction }

特性

公共函數

QXmlStreamReader (const char * data )
QXmlStreamReader (const QString & data )
QXmlStreamReader (const QByteArray & data )
QXmlStreamReader (QIODevice * device )
QXmlStreamReader ()
~QXmlStreamReader ()
void addData (const QByteArray & data )
void addData (const QString & data )
void addData (const char * data )
void addExtraNamespaceDeclaration (const QXmlStreamNamespaceDeclaration & extraNamespaceDeclaration )
void addExtraNamespaceDeclarations (const QXmlStreamNamespaceDeclarations & extraNamespaceDeclarations )
bool atEnd () const
QXmlStreamAttributes attributes () const
qint64 characterOffset () const
void clear ()
qint64 columnNumber () const
QIODevice * device () const
QStringRef documentEncoding () const
QStringRef documentVersion () const
QStringRef dtdName () const
QStringRef dtdPublicId () const
QStringRef dtdSystemId () const
QXmlStreamEntityDeclarations entityDeclarations () const
int entityExpansionLimit () const
QXmlStreamEntityResolver * entityResolver () const
QXmlStreamReader::Error error () const
QString errorString () const
bool hasError () const
bool isCDATA () const
bool isCharacters () const
bool isComment () const
bool isDTD () const
bool isEndDocument () const
bool isEndElement () const
bool isEntityReference () const
bool isProcessingInstruction () const
bool isStandaloneDocument () const
bool isStartDocument () const
bool isStartElement () const
bool isWhitespace () const
qint64 lineNumber () const
QStringRef name () const
QXmlStreamNamespaceDeclarations namespaceDeclarations () const
bool namespaceProcessing () const
QStringRef namespaceUri () const
QXmlStreamNotationDeclarations notationDeclarations () const
QStringRef prefix () const
QStringRef processingInstructionData () const
QStringRef processingInstructionTarget () const
QStringRef qualifiedName () const
void raiseError (const QString & message = QString())
QString readElementText (QXmlStreamReader::ReadElementTextBehaviour behaviour = ErrorOnUnexpectedElement)
QXmlStreamReader::TokenType readNext ()
bool readNextStartElement ()
void setDevice (QIODevice * device )
void setEntityExpansionLimit (int limit )
void setEntityResolver (QXmlStreamEntityResolver * resolver )
void setNamespaceProcessing ( bool )
void skipCurrentElement ()
QStringRef text () const
QString tokenString () const
QXmlStreamReader::TokenType tokenType () const

詳細描述

QXmlStreamReader 提供剖析格式良好 XML 的簡單流 API。它是替代以先將完整 XML 載入 DOM 樹 (見 QDomDocument )。 QXmlStreamReader 讀取數據從 QIODevice (見 setDevice ()),或從原生 QByteArray (見 addData ()).

Qt 提供 QXmlStreamWriter 為寫入 XML。

The basic concept of a stream reader is to report an XML document as a stream of tokens, similar to SAX. The main difference between QXmlStreamReader and SAX is how these XML tokens are reported. With SAX, the application must provide handlers (callback functions) that receive so-called XML events from the parser at the parser's convenience. With QXmlStreamReader, the application code itself drives the loop and pulls tokens from the reader, one after another, as it needs them. This is done by calling readNext (), where the reader reads from the input stream until it completes the next token, at which point it returns the tokenType (). A set of convenient functions including isStartElement () 和 text () can then be used to examine the token to obtain information about what has been read. The big advantage of this pulling approach is the possibility to build recursive descent parsers with it, meaning you can split your XML parsing code easily into different methods or classes. This makes it easy to keep track of the application's own state when parsing XML.

A typical loop with QXmlStreamReader looks like this:

  QXmlStreamReader xml;
  ...
  while (!xml.atEnd()) {
        xml.readNext();
        ... // do processing
  }
  if (xml.hasError()) {
        ... // do error handling
  }
					

QXmlStreamReader is a well-formed XML 1.0 parser that does not include external parsed entities. As long as no error occurs, the application code can thus be assured, that

  • the data provided by the stream reader satisfies the W3C's criteria for well-formed XML,
  • tokens are provided in a valid order.

Unless QXmlStreamReader raises an error, it guarantees the following:

  • All tags are nested and closed properly.
  • References to internal entities have been replaced with the correct replacement text.
  • Attributes have been normalized or added according to the internal subset of the DTD .
  • Tokens of type StartDocument happen before all others, aside from comments and processing instructions.
  • At most one DOCTYPE element (a token of type DTD ) is present.
  • If present, the DOCTYPE appears before all other elements, aside from StartDocument , comments and processing instructions.

In particular, once any token of type StartElement , EndElement , Characters , EntityReference or EndDocument is seen, no tokens of type StartDocument or DTD will be seen. If one is present in the input stream, out of order, an error is raised.

注意: The token types 注釋 and ProcessingInstruction may appear anywhere in the stream.

若剖析時齣現錯誤, atEnd () 和 hasError () 返迴 true,和 error () 返迴齣現的錯誤。函數 errorString (), lineNumber (), columnNumber (),和 characterOffset () are for constructing an appropriate error or warning message. To simplify application code, QXmlStreamReader contains a raiseError () mechanism that lets you raise custom errors that trigger the same error handling described.

The QXmlStream 書簽範例 illustrates how to use the recursive descent technique to read an XML bookmark file (XBEL) with a stream reader.

名稱空間

QXmlStream understands and resolves XML namespaces. E.g. in case of a StartElement , namespaceUri () returns the namespace the element is in, and name () returns the element's local name. The combination of namespaceUri and name uniquely identifies an element. If a namespace prefix was not declared in the XML entities parsed by the reader, the namespaceUri is empty.

If you parse XML data that does not utilize namespaces according to the XML specification or doesn't use namespaces at all, you can use the element's qualifiedName () instead. A qualified name is the element's prefix () followed by colon followed by the element's local name () - exactly like the element appears in the raw XML data. Since the mapping namespaceUri to prefix is neither unique nor universal, qualifiedName () should be avoided for namespace-compliant XML data.

In order to parse standalone documents that do use undeclared namespace prefixes, you can turn off namespace processing completely with the namespaceProcessing 特性。

增量剖析

QXmlStreamReader is an incremental parser. It can handle the case where the document can't be parsed all at once because it arrives in chunks (e.g. from multiple files, or over a network connection). When the reader runs out of data before the complete document has been parsed, it reports a PrematureEndOfDocumentError . When more data arrives, either because of a call to addData () or because more data is available through the network device (), the reader recovers from the PrematureEndOfDocumentError error and continues parsing the new data with the next call to readNext ().

For example, if your application reads data from the network using a network access manager , you would issue a network request to the manager and receive a network reply in return. Since a QNetworkReply QIODevice , you connect its readyRead() signal to a custom slot, e.g. slotReadyRead() in the code snippet shown in the discussion for QNetworkAccessManager . In this slot, you read all available data with readAll() and pass it to the XML stream reader using addData (). Then you call your custom parsing function that reads the XML events from the reader.

性能和內存消耗

QXmlStreamReader is memory-conservative by design, since it doesn't store the entire XML document tree in memory, but only the current token at the time it is reported. In addition, QXmlStreamReader avoids the many small string allocations that it normally takes to map an XML document to a convenient and Qt-ish API. It does this by reporting all string data as QStringRef rather than real QString 對象。 QStringRef is a thin wrapper around QString substrings that provides a subset of the QString API without the memory allocation and reference-counting overhead. Calling toString() on any of those objects returns an equivalent real QString 對象。

成員類型文檔編製

enum QXmlStreamReader:: Error

此枚舉指定不同錯誤情況

常量 描述
QXmlStreamReader::NoError 0 沒有齣現錯誤。
QXmlStreamReader::CustomError 2 引發自定義錯誤采有 raiseError ()
QXmlStreamReader::NotWellFormedError 3 The parser internally raised an error due to the read XML not being well-formed.
QXmlStreamReader::PrematureEndOfDocumentError 4 The input stream ended before a well-formed XML document was parsed. Recovery from this error is possible if more XML arrives in the stream, either by calling addData () or by waiting for it to arrive on the device ().
QXmlStreamReader::UnexpectedElementError 1 The parser encountered an element or token that was different to those it expected.

enum QXmlStreamReader:: ReadElementTextBehaviour

此枚舉指定不同行為在 readElementText ().

常量 描述
QXmlStreamReader::ErrorOnUnexpectedElement 0 Raise an UnexpectedElementError and return what was read so far when a child element is encountered.
QXmlStreamReader::IncludeChildElements 1 Recursively include the text from child elements.
QXmlStreamReader::SkipChildElements 2 跳過子級元素。

該枚舉在 Qt 4.6 引入或被修改。

enum QXmlStreamReader:: TokenType

此枚舉指定讀取器剛剛讀取的令牌類型。

常量 描述
QXmlStreamReader::NoToken 0 讀取器尚未讀取任何內容。
QXmlStreamReader::Invalid 1 發生錯誤,報告在 error () 和 errorString ().
QXmlStreamReader::StartDocument 2 The reader reports the XML version number in documentVersion (), and the encoding as specified in the XML document in documentEncoding (). If the document is declared standalone, isStandaloneDocument () 返迴 true ;否則返迴 false .
QXmlStreamReader::EndDocument 3 The reader reports the end of the document.
QXmlStreamReader::StartElement 4 The reader reports the start of an element with namespaceUri () 和 name (). Empty elements are also reported as StartElement, followed directly by EndElement. The convenience function readElementText () can be called to concatenate all content until the corresponding EndElement. Attributes are reported in attributes (), namespace declarations in namespaceDeclarations ().
QXmlStreamReader::EndElement 5 The reader reports the end of an element with namespaceUri () 和 name ().
QXmlStreamReader::Characters 6 The reader reports characters in text (). If the characters are all white-space, isWhitespace () 返迴 true . If the characters stem from a CDATA section, isCDATA () 返迴 true .
QXmlStreamReader::Comment 7 讀取器報告注釋按 text ().
QXmlStreamReader::DTD 8 The reader reports a DTD in text (), notation declarations in notationDeclarations (), and entity declarations in entityDeclarations (). Details of the DTD declaration are reported in in dtdName (), dtdPublicId (),和 dtdSystemId ().
QXmlStreamReader::EntityReference 9 The reader reports an entity reference that could not be resolved. The name of the reference is reported in name (), the replacement text in text ().
QXmlStreamReader::ProcessingInstruction 10 The reader reports a processing instruction in processingInstructionTarget () 和 processingInstructionData ().

特性文檔編製

namespaceProcessing : bool

流讀取器的名稱空間處理標誌

此特性控製流讀取器是否處理名稱空間。若啓用,讀取器處理名稱空間,否則不。

默認情況下,名稱空間處理是啓用的。

訪問函數:

bool namespaceProcessing () const
void setNamespaceProcessing ( bool )

成員函數文檔編製

QXmlStreamReader:: QXmlStreamReader (const char * data )

創建的新流讀取器讀取自 data .

另請參閱 addData (), clear (),和 setDevice ().

QXmlStreamReader:: QXmlStreamReader (const QString & data )

創建的新流讀取器讀取自 data .

This function should only be used if the XML header either says the encoding is "UTF-8" or lacks any encoding information (the latter is the case of QXmlStreamWriter writing to a QString ). Any other encoding is likely going to cause data corruption ("mojibake").

另請參閱 addData (), clear (),和 setDevice ().

QXmlStreamReader:: QXmlStreamReader (const QByteArray & data )

創建的新流讀取器讀取自 data .

另請參閱 addData (), clear (),和 setDevice ().

QXmlStreamReader:: QXmlStreamReader ( QIODevice * device )

創建的新流讀取器讀取自 device .

另請參閱 setDevice () 和 clear ().

QXmlStreamReader:: QXmlStreamReader ()

構造流讀取器。

另請參閱 setDevice () 和 addData ().

QXmlStreamReader:: ~QXmlStreamReader ()

銷毀讀取器。

void QXmlStreamReader:: addData (const QByteArray & data )

添加更多 data for the reader to read. This function does nothing if the reader has a device ().

另請參閱 readNext () 和 clear ().

void QXmlStreamReader:: addData (const QString & data )

添加更多 data for the reader to read. This function does nothing if the reader has a device ().

另請參閱 readNext () 和 clear ().

void QXmlStreamReader:: addData (const char * data )

添加更多 data for the reader to read. This function does nothing if the reader has a device ().

另請參閱 readNext () 和 clear ().

void QXmlStreamReader:: addExtraNamespaceDeclaration (const QXmlStreamNamespaceDeclaration & extraNamespaceDeclaration )

添加 extraNamespaceDeclaration . The declaration will be valid for children of the current element, or - should the function be called before any elements are read - for the entire XML document.

該函數在 Qt 4.4 引入。

另請參閱 namespaceDeclarations (), addExtraNamespaceDeclarations (),和 setNamespaceProcessing ().

void QXmlStreamReader:: addExtraNamespaceDeclarations (const QXmlStreamNamespaceDeclarations & extraNamespaceDeclarations )

Adds a vector of declarations specified by extraNamespaceDeclarations .

該函數在 Qt 4.4 引入。

另請參閱 namespaceDeclarations () 和 addExtraNamespaceDeclaration ().

bool QXmlStreamReader:: atEnd () const

返迴 true if the reader has read until the end of the XML document, or if an error () has occurred and reading has been aborted. Otherwise, it returns false .

當 atEnd() 和 hasError () 返迴 true 且 error () 返迴 PrematureEndOfDocumentError , it means the XML has been well-formed so far, but a complete XML document has not been parsed. The next chunk of XML can be added with addData (), if the XML is being read from a QByteArray , or by waiting for more data to arrive if the XML is being read from a QIODevice . Either way, atEnd() will return false once more data is available.

另請參閱 hasError (), error (), device (),和 QIODevice::atEnd ().

QXmlStreamAttributes QXmlStreamReader:: attributes () const

返迴屬性為 StartElement .

qint64 QXmlStreamReader:: characterOffset () const

返迴當前字符偏移,從 0 開始。

另請參閱 lineNumber () 和 columnNumber ().

void QXmlStreamReader:: clear ()

移除任何 device () or data from the reader and resets its internal state to the initial state.

另請參閱 addData ().

qint64 QXmlStreamReader:: columnNumber () const

返迴當前列號,從 0 開始。

另請參閱 lineNumber () 和 characterOffset ().

QIODevice *QXmlStreamReader:: device () const

返迴被當前設備關聯的 QXmlStreamReader ,或 nullptr 若沒有設備被賦值。

另請參閱 setDevice ().

QStringRef QXmlStreamReader:: documentEncoding () const

tokenType () 是 StartDocument , this function returns the encoding string as specified in the XML declaration. Otherwise an empty string is returned.

該函數在 Qt 4.4 引入。

QStringRef QXmlStreamReader:: documentVersion () const

tokenType () 是 StartDocument , this function returns the version string as specified in the XML declaration. Otherwise an empty string is returned.

該函數在 Qt 4.4 引入。

QStringRef QXmlStreamReader:: dtdName () const

tokenType () 是 DTD ,此函數返迴 DTD 名稱。否則返迴空字符串。

該函數在 Qt 4.4 引入。

QStringRef QXmlStreamReader:: dtdPublicId () const

tokenType () 是 DTD , this function returns the DTD's public identifier. Otherwise an empty string is returned.

該函數在 Qt 4.4 引入。

QStringRef QXmlStreamReader:: dtdSystemId () const

tokenType () 是 DTD , this function returns the DTD's system identifier. Otherwise an empty string is returned.

該函數在 Qt 4.4 引入。

QXmlStreamEntityDeclarations QXmlStreamReader:: entityDeclarations () const

tokenType () 是 DTD , this function returns the DTD's unparsed (external) entity declarations. Otherwise an empty vector is returned.

The QXmlStreamEntityDeclarations class is defined to be a QVector of QXmlStreamEntityDeclaration .

int QXmlStreamReader:: entityExpansionLimit () const

Returns the maximum amount of characters a single entity is allowed to expand into. If a single entity expands past the given limit, the document is not considered well formed.

該函數在 Qt 5.15 引入。

另請參閱 setEntityExpansionLimit .

QXmlStreamEntityResolver *QXmlStreamReader:: entityResolver () const

返迴實體解析器,或 nullptr 若沒有實體解析器。

該函數在 Qt 4.4 引入。

另請參閱 setEntityResolver ().

QXmlStreamReader::Error QXmlStreamReader:: error () const

返迴當前錯誤的類型,或 NoError 若沒有齣現錯誤。

另請參閱 errorString () 和 raiseError ().

QString QXmlStreamReader:: errorString () const

返迴錯誤消息,設置采用 raiseError ().

另請參閱 error (), lineNumber (), columnNumber (),和 characterOffset ().

bool QXmlStreamReader:: hasError () const

返迴 true 若有發生錯誤,否則 false .

另請參閱 errorString () 和 error ().

bool QXmlStreamReader:: isCDATA () const

返迴 true 若讀取器報告源自 CDATA 區間的字符;否則返迴 false .

另請參閱 isCharacters () 和 text ().

bool QXmlStreamReader:: isCharacters () const

返迴 true if tokenType () 等於 Characters ;否則返迴 false .

另請參閱 isWhitespace () 和 isCDATA ().

bool QXmlStreamReader:: isComment () const

返迴 true if tokenType () 等於 注釋 ;否則返迴 false .

bool QXmlStreamReader:: isDTD () const

返迴 true if tokenType () 等於 DTD ;否則返迴 false .

bool QXmlStreamReader:: isEndDocument () const

返迴 true if tokenType () 等於 EndDocument ;否則返迴 false .

bool QXmlStreamReader:: isEndElement () const

返迴 true if tokenType () 等於 EndElement ;否則返迴 false .

bool QXmlStreamReader:: isEntityReference () const

返迴 true if tokenType () 等於 EntityReference ;否則返迴 false .

bool QXmlStreamReader:: isProcessingInstruction () const

返迴 true if tokenType () 等於 ProcessingInstruction ;否則返迴 false .

bool QXmlStreamReader:: isStandaloneDocument () const

返迴 true if this document has been declared standalone in the XML declaration; otherwise returns false .

若未剖析 XML 聲明,此函數返迴 false .

bool QXmlStreamReader:: isStartDocument () const

返迴 true if tokenType () 等於 StartDocument ;否則返迴 false .

bool QXmlStreamReader:: isStartElement () const

返迴 true if tokenType () 等於 StartElement ;否則返迴 false .

bool QXmlStreamReader:: isWhitespace () const

返迴 true if the reader reports characters that only consist of white-space; otherwise returns false .

另請參閱 isCharacters () 和 text ().

qint64 QXmlStreamReader:: lineNumber () const

返迴當前行號,從 1 開始。

另請參閱 columnNumber () 和 characterOffset ().

QStringRef QXmlStreamReader:: name () const

返迴本地名稱為 StartElement , EndElement ,或 EntityReference .

另請參閱 namespaceUri () 和 qualifiedName ().

QXmlStreamNamespaceDeclarations QXmlStreamReader:: namespaceDeclarations () const

tokenType () 是 StartElement , this function returns the element's namespace declarations. Otherwise an empty vector is returned.

The QXmlStreamNamespaceDeclarations class is defined to be a QVector of QXmlStreamNamespaceDeclaration .

另請參閱 addExtraNamespaceDeclaration () 和 addExtraNamespaceDeclarations ().

QStringRef QXmlStreamReader:: namespaceUri () const

返迴 namespaceUri 為 StartElement or EndElement .

另請參閱 name () 和 qualifiedName ().

QXmlStreamNotationDeclarations QXmlStreamReader:: notationDeclarations () const

tokenType () 是 DTD , this function returns the DTD's notation declarations. Otherwise an empty vector is returned.

The QXmlStreamNotationDeclarations class is defined to be a QVector of QXmlStreamNotationDeclaration .

QStringRef QXmlStreamReader:: prefix () const

返迴前綴為 StartElement or EndElement .

該函數在 Qt 4.4 引入。

另請參閱 name () 和 qualifiedName ().

QStringRef QXmlStreamReader:: processingInstructionData () const

返迴數據為 ProcessingInstruction .

QStringRef QXmlStreamReader:: processingInstructionTarget () const

Returns the target of a ProcessingInstruction .

QStringRef QXmlStreamReader:: qualifiedName () const

Returns the qualified name of a StartElement or EndElement ;

A qualified name is the raw name of an element in the XML data. It consists of the namespace prefix, followed by colon, followed by the element's local name. Since the namespace prefix is not unique (the same prefix can point to different namespaces and different prefixes can point to the same namespace), you shouldn't use qualifiedName(), but the resolved namespaceUri () and the attribute's local name ().

另請參閱 name (), prefix (),和 namespaceUri ().

void QXmlStreamReader:: raiseError (const QString & message = QString())

引發自定義錯誤采用可選錯誤 message .

另請參閱 error () 和 errorString ().

QString QXmlStreamReader:: readElementText ( QXmlStreamReader::ReadElementTextBehaviour behaviour = ErrorOnUnexpectedElement)

Convenience function to be called in case a StartElement was read. Reads until the corresponding EndElement and returns all text in-between. In case of no error, the current token (see tokenType ()) after having called this function is EndElement .

函數串聯 text () 當它讀取 Characters or EntityReference 令牌,但跳過 ProcessingInstruction and 注釋 . If the current token is not StartElement , an empty string is returned.

The behaviour defines what happens in case anything else is read before reaching EndElement . The function can include the text from child elements (useful for example for HTML), ignore child elements, or raise an UnexpectedElementError and return what was read so far (default).

該函數在 Qt 4.6 引入。

QXmlStreamReader::TokenType QXmlStreamReader:: readNext ()

讀取下一令牌並返迴其類型。

With one exception, once an error () is reported by readNext(), further reading of the XML stream is not possible. Then atEnd () 返迴 true , hasError () 返迴 true , and this function returns QXmlStreamReader::Invalid .

The exception is when error () 返迴 PrematureEndOfDocumentError . This error is reported when the end of an otherwise well-formed chunk of XML is reached, but the chunk doesn't represent a complete XML document. In that case, parsing can be resumed by calling addData () to add the next chunk of XML, when the stream is being read from a QByteArray , or by waiting for more data to arrive when the stream is being read from a device ().

另請參閱 tokenType () 和 tokenString ().

bool QXmlStreamReader:: readNextStartElement ()

Reads until the next start element within the current element. Returns true when a start element was reached. When the end element was reached, or when an error occurred, false is returned.

The current element is the element matching the most recently parsed start element of which a matching end element has not yet been reached. When the parser has reached the end element, the current element becomes the parent element.

This is a convenience function for when you're only concerned with parsing XML elements. The QXmlStream 書簽範例 makes extensive use of this function.

該函數在 Qt 4.6 引入。

另請參閱 readNext ().

void QXmlStreamReader:: setDevice ( QIODevice * device )

把當前設備設為 device 。設置設備將流重置到其初始狀態。

另請參閱 device () 和 clear ().

void QXmlStreamReader:: setEntityExpansionLimit ( int limit )

Sets the maximum amount of characters a single entity is allowed to expand into to limit . If a single entity expands past the given limit, the document is not considered well formed.

The limit is there to prevent DoS attacks when loading unknown XML documents where recursive entity expansion could otherwise exhaust all available memory.

此特性的默認值為 4096 字符。

該函數在 Qt 5.15 引入。

另請參閱 entityExpansionLimit .

void QXmlStreamReader:: setEntityResolver ( QXmlStreamEntityResolver * resolver )

使 resolver the new entityResolver ().

The stream reader does not take ownership of the resolver. It's the callers responsibility to ensure that the resolver is valid during the entire life-time of the stream reader object, or until another resolver or nullptr 有設置。

該函數在 Qt 4.4 引入。

另請參閱 entityResolver ().

void QXmlStreamReader:: skipCurrentElement ()

Reads until the end of the current element, skipping any child nodes. This function is useful for skipping unknown elements.

The current element is the element matching the most recently parsed start element of which a matching end element has not yet been reached. When the parser has reached the end element, the current element becomes the parent element.

該函數在 Qt 4.6 引入。

QStringRef QXmlStreamReader:: text () const

Returns the text of Characters , 注釋 , DTD ,或 EntityReference .

QString QXmlStreamReader:: tokenString () const

以字符串形式返迴讀取器的當前令牌。

另請參閱 tokenType ().

QXmlStreamReader::TokenType QXmlStreamReader:: tokenType () const

返迴當前令牌類型。

當前令牌也可以查詢采用方便函數 isStartDocument (), isEndDocument (), isStartElement (), isEndElement (), isCharacters (), isComment (), isDTD (), isEntityReference (),和 isProcessingInstruction ().

另請參閱 tokenString ().