Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How can I use RegExp to parse <p> tag
Forum Updated to NodeBB v4.3 + New Features

How can I use RegExp to parse <p> tag

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.8k Views 1 Watching
  • 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.
  • X Offline
    X Offline
    xiazhouquan
    wrote on last edited by
    #1

    I want to parse <p> tag ,using function in qml,but nothing went on!
    here is the simple xml
    @
    <description>
    <img src="http://manybooks.net/original_covers/w/wyssjr/wyssjr3480834808-8-thumb.jpg" hspace="10" border="0" alt="Cover image for Swiss Family Robinson, The" align="left" /><p>or, Adventures on a Desert Island </p><p>Author: Jean Rudolph Wyss </p><p>Language: English </p><p>Published: 1916 </p>
    </description>
    @

    the question is how can I use RegExp to get the content of <p> tag

    thank you very much!

    业精于勤荒于嬉,行成于思毁于随

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Very simple: QRegExp is not a parser. Do not use it to parse XML. Instead, use the right tool for the job: QXmlStreamReader or XMLPatterns. Believe me, you will make your life easier that way. You might be able to eat your soup with a fork, but using a spoon will certainly result in a more pleasant eating experience. The same goes for solving programming problems.

      Because you want to do that from QML, you'll either need to such such a facility from javascript (is there such a thing? I don't know.), or expose a C++ object that does the work for you into your QML context.

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xiazhouquan
        wrote on last edited by
        #3

        Thank you for your advice,now I use javascript RegExp to get the tag content,but QXmlStreamReader is extremely nice.Thanks again !My regards!
        [quote author="Andre" date="1308471518"]Very simple: QRegExp is not a parser. Do not use it to parse XML. Instead, use the right tool for the job: QXmlStreamReader or XMLPatterns. Believe me, you will make your life easier that way. You might be able to eat your soup with a fork, but using a spoon will certainly result in a more pleasant eating experience. The same goes for solving programming problems.

        Because you want to do that from QML, you'll either need to such such a facility from javascript (is there such a thing? I don't know.), or expose a C++ object that does the work for you into your QML context. [/quote]

        业精于勤荒于嬉,行成于思毁于随

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved