Qt Forum

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

    Unsolved How can I parsing html in Qt by C++?

    Mobile and Embedded
    2
    6
    1669
    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.
    • I
      Ibrahim last edited by

      Hi; I want to parsing html in Qt by C++. I will develop html parser for desktop and mobile application. Which can I use C++ module for html parser? Thanks.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        What kind of parsing do you have in mind ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        I 1 Reply Last reply Reply Quote 0
        • I
          Ibrahim @SGaist last edited by

          @SGaist Example: <html><body><a href="www.xxx.yyy">Click Me!</a></body></html>
          I want to get www.xxx.yyy and Click Me!. How can I do that?

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            There's the QWebElement class that could be of use but it's in the deprecated QtWebKit module.

            But are you looking for a library to do the parsing or write your own ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            I 1 Reply Last reply Reply Quote 0
            • I
              Ibrahim @SGaist last edited by

              @SGaist I looked some html parser library. There is not a library or module in Qt 5.5.1 or Qt 5.6? Else should I use a html parser library or write my own library by QRegExp?

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                If you know in advance the html you want to parse and that it fits in the xml category you can use the QXmlStreamReader class. For example, you html snippet should be parsed without any problem.

                If you want to use regular expressions go with QRegularExpression.

                Again, it depends on what exactly you need. If it's to parse any and every html page then you should consider a dedicated library.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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