Results 1 to 3 of 3

Thread: How to search a string in xml file with Qt Dom classes

  1. #1
    Join Date
    Oct 2006
    Posts
    1
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to search a string in xml file with Qt Dom classes

    How to search a string in xml file with Qt Dom classes
    I want to use xml file like sql database file.how to i can search a string with qtxml dom classes in xml file.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to search a string in xml file with Qt Dom classes

    You may start with reading docs:

    pay special attention to "Detailed Description" sections. There are example pieces of code..
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to search a string in xml file with Qt Dom classes

    If you need DOM functionality, then you need to recurse over children of each element looking for a node you need, for example:

    Qt Code:
    1. QDomElement findElement(QDomElement parent, const QString &textToFind){
    2. for(QDomElement elem = parent.firstChildElement();
    3. !elem.isNull();
    4. elem = elem.nextSiblingElement()){
    5. if(elem.text()==textToFind) return elem;
    6. QDomElement e = findElement(elem, textToFind);
    7. if(!e.isNull()) return e;
    8. }
    9. return QDomElement();
    10. }
    To copy to clipboard, switch view to plain text mode 

  4. The following 2 users say thank you to wysota for this useful post:

    doganay44 (8th October 2006), wolly82 (9th April 2009)

Similar Threads

  1. read file from end to beginning..
    By soul_rebel in forum Qt Programming
    Replies: 11
    Last Post: 4th June 2012, 01:20
  2. Draging a non-existing file to the Windows Desktop
    By klaus1111 in forum Qt Programming
    Replies: 13
    Last Post: 20th September 2007, 11:47
  3. SQLite-DB in a qrc file
    By Lykurg in forum Qt Programming
    Replies: 5
    Last Post: 31st July 2006, 19:24
  4. Replies: 11
    Last Post: 4th July 2006, 15:09
  5. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 14:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.