QXmlContentHandler(3qt)
π QXmlContentHandler π β the QXmlContentHandler(3qt) manual, bestie edition
okay so. sit down. hydrate. we're talking about QXmlContentHandler, and honestly? she's iconic. she's the interface that reports the logical content of XML data. that's the whole vibe. no cap.
β¨ NAME β¨
QXmlContentHandler β the interface that reports the logical content of XML data. that's it. that's her whole job description. π
πΈ SYNOPSIS πΈ
real talk first: all the functions in this class are reentrant when Qt is built with thread support.</p>
(yeah, that stray </p> is in the original. we keep it. we don't ask questions. π)
#include <qxml.h>
Inherited by QXmlDefaultHandler.
π Public Members
virtual void setDocumentLocator ( QXmlLocator * locator ) = 0
virtual bool startDocument () = 0
virtual bool endDocument () = 0
virtual bool startPrefixMapping ( const QString & prefix, const QString
& uri ) = 0
virtual bool endPrefixMapping ( const QString & prefix ) = 0
virtual bool startElement ( const QString & namespaceURI, const QString
& localName, const QString & qName, const QXmlAttributes & atts ) =
0
virtual bool endElement ( const QString & namespaceURI, const QString &
localName, const QString & qName ) = 0
virtual bool characters ( const QString & ch ) = 0
virtual bool ignorableWhitespace ( const QString & ch ) = 0
virtual bool processingInstruction ( const QString & target, const
QString & data ) = 0
virtual bool skippedEntity ( const QString & name ) = 0
virtual QString errorString () = 0
look at that lineup. every single one is = 0, meaning they're all pure virtual and it's on you to implement them. she's an interface, she doesn't do the work, she just tells you when things happen. main character energy tbh. π
π¦ DESCRIPTION π¦
The QXmlContentHandler class provides an interface to report the logical content of XML data.
If your app needs to be kept in the loop about basic parsing events, you implement this interface and switch it on with QXmlReader::setContentHandler(). then the reader can slide into your DMs with basic document-related events β start and end of elements, character data, all of it β through this interface. π«Ά
okay and here's the thing that matters: the order of events in this interface is very important, and it mirrors the order of information in the document itself. like, it's not vibes-based. for example, all of an element's content (character data, processing instructions, and sub-elements) appears, in order, between the startElement() event and the corresponding endElement() event. nesting is the whole point bestie. π
The class QXmlDefaultHandler provides a default implementation for this interface; subclassing from the QXmlDefaultHandler class is very convenient if you only want to be informed of some parsing events. like, if you're not trying to do the absolute most. π
so the rundown, in order:
startDocument()is called at the start of the document, andendDocument()is called at the end.- Before parsing begins,
setDocumentLocator()is called. - For each element,
startElement()is called, withendElement()being called at the end of each element. characters()is called with chunks of character data;ignorableWhitespace()is called with chunks of whitespace andprocessingInstruction()is called with processing instructions.- If an entity is skipped,
skippedEntity()is called. - At the beginning of prefix-URI scopes,
startPrefixMapping()is called.
See also the Introduction to SAX2.
See also QXmlDTDHandler, QXmlDeclHandler, QXmlEntityResolver, QXmlErrorHandler, QXmlLexicalHandler, and XML.
π MEMBER FUNCTION DOCUMENTATION π
bool QXmlContentHandler::characters ( const QString & ch ) [pure virtual]
The reader calls this function when it has parsed a chunk of character data β and yes, that means either normal character data or character data inside a CDATA section. if you need to distinguish between those two types you must use QXmlLexicalHandler::startCDATA() and QXmlLexicalHandler::endCDATA(). that's the only way, bestie. π₯
The character data is reported in ch.
Some readers report whitespace in element content using the ignorableWhitespace() function rather than using this one. rude? maybe. legal? yes.
A reader may report the character data of an element in more than one chunk; e.g. a reader might want to report "a<b" in three characters() events ("a ", "<" and " b"). so don't assume one call = one full string. that's a trap. π
If this function returns FALSE the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
bool QXmlContentHandler::endDocument () [pure virtual]
The reader calls this function after it has finished parsing. It is called just once, and is the last handler function called. It is called after the reader has read all input or has abandoned parsing because of a fatal error. so like... she shows up whether it went great or it went down in flames. π
If this function returns FALSE the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
See also startDocument().
bool QXmlContentHandler::endElement ( const QString & namespaceURI, const QString & localName, const QString & qName ) [pure virtual]
The reader calls this function when it has parsed an end element tag with the qualified name qName, the local name localName and the namespace URI namespaceURI.
If this function returns FALSE the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
See also the namespace description.
See also startElement().
Example: xml/tagreader/structureparser.cpp.
bool QXmlContentHandler::endPrefixMapping ( const QString & prefix ) [pure virtual]
The reader calls this function to signal the end of a prefix mapping for the prefix prefix. closing the loop, as she should. π
If this function returns FALSE the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
See also the namespace description.
See also startPrefixMapping().
QString QXmlContentHandler::errorString () [pure virtual]
The reader calls this function to get an error string, e.g. if any of the handler functions returns FALSE. so when something goes wrong, this is the one who has to explain it. the emotional labor is real. π«Ά
bool QXmlContentHandler::ignorableWhitespace ( const QString & ch ) [pure virtual]
Some readers may use this function to report each chunk of whitespace in element content. The whitespace is reported in ch.
If this function returns FALSE the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
bool QXmlContentHandler::processingInstruction ( const QString & target, const QString & data ) [pure virtual]
The reader calls this function when it has parsed a processing instruction.
target is the target name of the processing instruction and data is the data in the processing instruction.
If this function returns FALSE the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
void QXmlContentHandler::setDocumentLocator ( QXmlLocator * locator ) [pure virtual]
The reader calls this function before it starts parsing the document. The argument locator is a pointer to a QXmlLocator which allows the application to get the parsing position within the document. so you always know where you are. navigation queen. π§
β οΈ Do not destroy the locator; it is destroyed when the reader is destroyed. (Do not use the locator after the reader is destroyed). seriously. do not. that's undefined-adjacent heartbreak territory and we're not doing that today. π
bool QXmlContentHandler::skippedEntity ( const QString & name ) [pure virtual]
Some readers may skip entities if they have not seen the declarations (e.g. because they are in an external DTD). If they do so they report that they skipped the entity called name by calling this function. it's giving "hey bestie just so you know, we skipped this one." πΈ
If this function returns FALSE the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
bool QXmlContentHandler::startDocument () [pure virtual]
The reader calls this function when it starts parsing the document. The reader calls this function just once, after the call to setDocumentLocator(), and before any other functions in this class or in the QXmlDTDHandler class are called. so she's early. she's punctual. she's the opening act. β
If this function returns FALSE the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
See also endDocument().
Example: xml/tagreader/structureparser.cpp.
bool QXmlContentHandler::startElement ( const QString & namespaceURI, const QString & localName, const QString & qName, const QXmlAttributes & atts ) [pure virtual]
The reader calls this function when it has parsed a start element tag.
There is a corresponding endElement() call when the corresponding end element tag is read. The startElement() and endElement() calls are always nested correctly. Empty element tags (e.g. <x/>) cause a startElement() call to be immediately followed by an endElement() call. no waiting, no gap, right on top of each other. obsessed. π
The attribute list provided only contains attributes with explicit values. The attribute list contains attributes used for namespace declaration (i.e. attributes starting with xmlns) only if the namespace-prefix property of the reader is TRUE.
now the arguments, one by one:
namespaceURIis the namespace URI, orQString::nullif the element has no namespace URI or if no namespace processing is done.localNameis the local name (without prefix), orQString::nullif no namespace processing is done.qNameis the qualified name (with prefix).attsare the attributes attached to the element. If there are no attributes,attsis an empty attributes object.
If this function returns FALSE the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
See also the namespace description.
See also endElement().
Example: xml/tagreader/structureparser.cpp.
bool QXmlContentHandler::startPrefixMapping ( const QString & prefix, const QString & uri ) [pure virtual]
The reader calls this function to signal the begin of a prefix-URI namespace mapping scope. This information is not necessary for normal namespace processing since the reader automatically replaces prefixes for element and attribute names. so like, it's extra. it's a bonus track. π΅
Note that startPrefixMapping() and endPrefixMapping() calls are not guaranteed to be properly nested relative to each other: all startPrefixMapping() events occur before the corresponding startElement() event, and all endPrefixMapping() events occur after the corresponding endElement() event, but their order is not otherwise guaranteed. so don't go assuming a tidy little nesting situation there. she said what she said. π
The argument prefix is the namespace prefix being declared and the argument uri is the namespace URI the prefix is mapped to.
If this function returns FALSE the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
See also the namespace description.
See also endPrefixMapping().
π SEE ALSO π
π COPYRIGHT π
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.
π AUTHOR π
Generated automatically from the source code.
okay so that's part 1 and there's more coming, so don't go anywhere bestie, we're not done yet π«Ά
π BUGS π
okay so if you find a bug in Qt β and bestie, you will find one eventually, it's giving "everyone does" β pls report it the way they describe at http://doc.trolltech.com/bughowto.html. π good bug reports literally help them help you, and that's the whole vibe. thank youuu π«Ά
also, real talk: the definitive Qt documentation is the HTML version, no cap. it lives at $QTDIR/doc/html and you can read it with Qt Assistant or just, like, any web browser π. this man page? it's a convenience for the girlies who prefer man pages, and it is not officially supported by Trolltech π. iykyk.
so if you spot actual errors in this manual page, pls send them to qt-bugs@trolltech.com β¨ and bestie, include these two things or they can't do anything:
- the name of the manual page:
qxmlcontenthandler.3qt - the Qt version:
3.3.8
that's it, that's the whole ask π
not me writing a whole man page and then the last thing is "yeah this format isn't officially supported" π iconic honestly
and that's the page, bestie!! this one came from Trolltech AS, dated 2 February 2007, and the page itself is QXmlContentHandler(3qt) π go forth and parse some XML, you're the main character fr fr π¦β¨π
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms