How can I use RegExp to parse <p> tag



  • 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!



  • 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.



  • 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]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.