Important: Please read the Qt Code of Conduct -

[SOLVED] How I can get HTML from QDomElement object.

  • Hi everyone!

    In my application i need to use HTML parser which give me access to dom elements. In result I've receive the object of class QDomElement and I can get all information (tag name, attribute, content, etc). When I try to get content of element using 'text()' method I've received the plain text. How I can get content with HTML tags?

    To parse the HTML I use the QXmlInputSource and libxml2.

  • If you need to save HTML content of some HTML tag from QDomElement instance you can use code:
    QDomElement itemTag =;
    QString content;
    QTextStream ts(&content);, itemTag.childNodes().count());
    qDebug()<<"content: "<<content; //<----Draw HTML code of itemTag

Log in to reply