Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    QML and Qt Quick
    1
    2
    793
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      shav last edited by

      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.

      Mac OS and iOS Developer

      1 Reply Last reply Reply Quote 0
      • S
        shav last edited by

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

        Mac OS and iOS Developer

        1 Reply Last reply Reply Quote 0
        • First post
          Last post