mafulechkaDec. 7, 2019, 8:11 a.m.

Parsing XML with Qt: Updates for Qt 6

It's been a long time since articles have touched on parsing XML documents with Qt. I would like to share some fresh news about the expected changes in the next releases. But first, let's recap what Qt currently provides for reading and writing XML documents.

Qt XML module

This module provides implementations for two different models for reading and writing XML files: the Document Object Model DOM and the Simple XML API (SAX). In the DOM, the complete XML file is loaded into memory and represented as a tree, making it easy to access and manipulate its nodes. DOM is generally used in applications where you don't care about memory. SAX, on the other hand, is an event-based XML parser and does not load the entire XML document into memory. Instead, it generates events for tokens during parsing, and the user can handle these events. The application must implement the handler interfaces (in whole or in part using QXmlDefaultHandler). Many people find this inconvenient as it forces them to structure their code around this model.

Another problem is that the current implementation of SAX (and by extension the DOM, since it's implemented using SAX) is not fully compatible with the XML standard. Given these shortcomings, Qt no longer recommends the use of SAX, and the decision has been made to deprecate these classes as of Qt 5.15.

QXmlStreamReader и QXmlStreamWriter

Fortunately, Qt provides XML streaming classes as a more convenient and XML-compliant alternative for working with XML files.

What will change in Qt 6?

As mentioned above, SAX classes will soon be deprecated, which means that QDomDocument will no longer be able to use them. That's why it was re-implemented using QXmlStreamReader. Qt 6 will switch to the new implementation, but older versions of Qt will still use the old implementation as the new one will bring a few behavioral changes and developers don't want to do that until Qt 6.

What does this change mean for Qt DOM users? Because QXmlStreamReader follows the XML specification more closely, QDomDocument will do the same starting with Qt 6. This will mean the following behavior changes for QDomDocument:

Attribute values will be normalized . For example, will be equivalent .
Identical qualified attribute names will no longer be allowed , ie element attributes must have unique names.
undeclared namespace prefixes will no longer be allowed .

If you are using QDomDocument and relying on any of these, consider updating your code and XML documents accordingly.

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.
Support the author Donate


Only authorized users can post comments.
Please, Log in or Sign up
Card image cap
Pulsum Via

Project for travelers from EVILEG.


Let me recommend you a great European Fornex hosting.

Fornex has proven itself to be a stable host over the years.

For Django projects I recommend VPS hosting

Following the link you will receive a 5% discount on shared hosting services, dedicated servers, VPS and VPN

View Hosting
Share on social networks

The EVILEG project has switched to a non-commercial basis and will develop solely on the enthusiasm of the site creator, the enthusiasm of users, donations and the hosting referral system

Thank you for your support

Available ways to support the project



C++ - Test 001. The first program and data types

  • Result:80points,
  • Rating points4

C++ - Test 001. The first program and data types

  • Result:66points,
  • Rating points-1

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:90points,
  • Rating points8
Last comments

Qt/C++ - Lesson 061. Adding images to the application using the Drag And Drop method from the file manager

Доброго времени суток. А если нужно и изображение и текст? Что-то потерялся немного.... // Вместо отрисовки иконки и текста будем отрисовывать только одно изображение // с н…

Qt/C++ - Lesson 004. QSqlTableModel – How to present the table from database?

error insert into TableExample " Количество параметров не совпадает" Я путь свой прописывала и даже бд удаляла, чтобы заново сделать, не работает. (всё остальное как у вас... Вроде ка…

Qt/C++ - Lesson 042. PopUp notification in the Gnome style using Qt

cialis powder comprare cialis online

GameDev on Qt - Tutorial 1. Track mouse movement in QGraphicsScene

Вполне возможно, что ты не закинул graphicsView в дизайнере в виджет

GameDev on Qt - Tutorial 1. Track mouse movement in QGraphicsScene

Кому интересно, поворот в slotTarget можно в одну строку организовать this->setRotation(90 + rotation() + qRadiansToDegrees(qAtan2(mapFromScene(point).y(), mapFromScene(point).x())));
Now discuss on the forum

Sorting the added QML elements in the ListModel

legal online pharmacy
  • Nomad
  • July 30, 2022, 5:42 a.m.

Как работать с HTMX?

Приветствую колеги. На днях наткнулся на вот это : На офф сайте написанно вот такая фраза: htmx gives you access to AJAX, CSS Transitions, We…
  • harisr
  • July 25, 2022, 2:56 a.m.

QT - Native App Integration

Привет, у нас уже есть собственное приложение для Android. Можем ли мы интегрировать пользовательское представление QT в приложение со всем приложением QT внутри представления. Если да, ука…

Правильный запуск сервера на vps - Django

О я как то себе дома локальный сервер создавал. Вам же нужно просто сделать ручками конфигурацию системы. Настроить Nginx ну либо Apache (тут кому что нравится). Соответственно БД и всё остально…

Распознание объектов

Я к тому, что, возможно, софт уже есть.
© EVILEG 2015-2022
Recommend hosting TIMEWEB