Chúng tôi cũng có thêm một dòng mới vào mô hình, mà sau đó chúng tôi sẽ lấp đầy với các giá trị. Nếu một thẻ mới bắt đầu, chúng ta cũng nên trống rỗng currentText, kể từ khi biến này chỉ nên có các văn bản giữa một cặp thẻ bắt đầu và kết thúc | The SAX2 API I a status and two comparisons. If this is not the case we set an error message and return from the method with false. If on the other hand we come across rss we first check the version number. We only support RSS version or a subset of this . We therefore reject other versions as a preventive measure. Now it is also time to set rssTagParsed to true so that we are not wrongly rejected by the first check on elements that we parse later. If we come across item then we change the status of inItem to true to distinguish the context of the tags as described above. We also add a new line to the model which we will then fill with values. If a new tag starts we should also empty currentText since this variable should only contain the text between a pair of start and end tags. Next the characters method is used to read in the data that lies between a pair of start and end tags. If the parser interprets this text as several consecutive texts for example a normal text and a CDATA section in which data may be enclosed in diamond operators without it being interpreted as XML we combine all the texts into one. Since no error can arise here from our perspective we return true in all circumstances rssreader continued bool RssHandler characters const QString str currentText str return true We insert the text collected in this way in endElement into the ready-to-use line of the model. Again we are not interested in namespaces but merely in the current tag which is waiting in the qName variable rssreader continued bool RssHandler endElement const QString namespaceURI const QString localName const QString qName if qName item inItem false else if qName title if inItem QModellndex idx itemModel- index 0 0 itemModel- setData idx currentText else if qName pubDate if inItem QModellndex idx itemModel- index 0 1 359 I Ị 13 Handling XML with QtXml itemModel- setData idx currentText else if qName description if inItem QModellndex idx .