Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QDomNode and CDATA



  • I'm using QDomDocument to retrieve items from an rss feed. Most rss feeds wrap the item descriptions (content:encoded or itunes:summary) with CDATA. Let's say that I'm using the code below to get the description.

    descriptionNode = QDomNode.namedItem("content:encoded");
    QString descriptionString = descriptionNode.toElement().text();
    

    Am I retrieving the CDATA as well as the text/html? How can I make sure that I'm only retrieving the text/html?


  • Lifetime Qt Champion

    Hi,

    Did you test that ?
    Do you have an XML example to check that ?



  • I tested an rss feed by retrieving the content:encoded text and setting the html of a QTextBrowser. It correctly displayed a few links so I know the html is working but I don't know if the CDATA is still present. Does QTextBrowser ignore the CDATA wrapper in setHtml()? Either way, I still don't know if I'm grabbing the CDATA from the element text.

    QTextBrowser->setHtml(descriptionString);
    

  • Lifetime Qt Champion

    You can check the html by retrieving it again from QTextBrowser. If you want to see exactly what is happening with QTextBrowser, then the simplest is to check it source.


Log in to reply