Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Performance Issue - Reading XML Values with 50-70 entry.
Forum Updated to NodeBB v4.3 + New Features

Performance Issue - Reading XML Values with 50-70 entry.

Scheduled Pinned Locked Moved Unsolved General and Desktop
xmlc++ qtperformance
2 Posts 2 Posters 924 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.
  • M Offline
    M Offline
    Mathan M
    wrote on last edited by p3c0
    #1

    Hi,

    I want to read the values from the reg.xml file. I tried in several methods using FirstChild.NodeValue()/NextSibling.Nodevalue/NextSiblingbyelements etc.,
    The working code is down below. But the code seems to be lengthy and suspect some thing shortcut must be there to extract the values.
    Not like converting to QNodeList,assisgn to domNode and again Qstring.

    Is this code is right, Since If 50-70 xml enteries there, Then there will be performance issue. Kindly suggest.

    reg.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <Download>
        <Maps MapSysID="0">
            <Title>MINOffice</Title>
            <itemId>dc96f92c410d4b93f0</itemId>
            <description>General map - 1 used for testing including thumbnail</description>
            <created>Wed Aug 31 09:38:49 2016 GMT+0100</created>
            <modified>Wed Aug 31 09:56:07 2016 GMT+0100</modified>
            <owner>manoharmdev</owner>
            <url>http://www.arssd.com/sharing/rest/content/items/dc96f92c410d4b93f0</url>
            <thumbnailUrl>http://www.arssd.com/sharing/rest/content/items/dc96f92c410d4b93f0/info/thumbnail/ThumbNail2.jpg</thumbnailUrl>
            <size>-1</size>
            <IsActive>1</IsActive>
            <EntryDate>Tuesday, October 04, 2016</EntryDate>
        </Maps>
        <Maps MapSysID="1">
            <Title>Prefecture</Title>
            <itemId>83d1c9aaf9d04e60a8c67</itemId>
            <description>CAR map-2 for testing purpose</description>
            <created>Wed Aug 31 09:52:23 2016 GMT+0100</created>
            <modified>Wed Aug 31 09:54:59 2016 GMT+0100</modified>
            <owner>manoharmdev</owner>
            <url>http://www.arssd.com/sharing/rest/content/items/83d1c9aaf9d04e60a8c67</url>
            <thumbnailUrl>http://www.arssd.com/sharing/rest/content/items/83d1c9aaf9d04e60a8c67/info/thumbnail/ThumbNail2.jpg</thumbnailUrl>
            <size>-1</size>
            <IsActive>1</IsActive>
            <EntryDate>Tuesday, October 04, 2016</EntryDate>
        </Maps>
    </Download>
    

    C++ code for reading the xml
    ----------------------------------------------:

            QDomNodeList objQDomNodeListOne = docElem.elementsByTagName("Maps");
            QDomNode objQDomNodeone = objQDomNodeListOne.at(0);
            int intDomNode = objQDomNodeListOne.count();
    
            QString strTitle ;
            QString strItemId ;
            QString strDescription;
            QString strCreated ;
            QString strModified ;
            QString strOwner ;
            QString strUrl  ;
            QString strThumbnailUrl;
            QString strSize;
            QString strIsActive;
            QString strEntryDate;
    
    
            for(int i = 0; i < objQDomNodeListOne.count(); i++)
               {
                   QDomNode elm = objQDomNodeListOne.at(i);
                   if(elm.isElement())
                   {
                       QDomElement e = elm.toElement();
    
                        QDomNodeList qNdlstTitle = e.elementsByTagName("Title");
                        QDomNodeList qNdlstitemId = e.elementsByTagName("itemId");
                        QDomNodeList qNdlstdescription = e.elementsByTagName("description");
                        QDomNodeList qNdlstcreated = e.elementsByTagName("created");
                        QDomNodeList qNdlstmodified = e.elementsByTagName("modified");
                        QDomNodeList qNdlstowner = e.elementsByTagName("owner");
                        QDomNodeList qNdlsturl = e.elementsByTagName("url");
                        QDomNodeList qNdlstthumbnailUrl = e.elementsByTagName("thumbnailUrl");
                        QDomNodeList qNdlstsize = e.elementsByTagName("size");
                        QDomNodeList qNdlstIsActive = e.elementsByTagName("IsActive");
                        QDomNodeList qNdlstEntryDate = e.elementsByTagName("EntryDate");
    
    
    
                        QDomNode qNodeTitle = qNdlstTitle.at(0);
                        QDomNode qNodeitemId = qNdlstitemId.at(0);
                        QDomNode qNodedescription = qNdlstdescription.at(0);
                        QDomNode qNodecreated = qNdlstcreated.at(0);
                        QDomNode qNodemodified = qNdlstmodified.at(0);
                        QDomNode qNodeowner = qNdlstowner.at(0);
                        QDomNode qNodeurl = qNdlsturl.at(0);
                        QDomNode qNodethumbnailUrl = qNdlstthumbnailUrl.at(0);
                        QDomNode qNodesize = qNdlstsize.at(0);
                        QDomNode qNodeIsActive = qNdlstIsActive.at(0);
                        QDomNode qNodeEntryDate = qNdlstEntryDate.at(0);
    
    
    
                         strTitle  = qNodeTitle.firstChild().nodeValue();
                         strItemId = qNodeitemId.firstChild().nodeValue();
                         strDescription  = qNodedescription.firstChild().nodeValue();
                         strCreated = qNodecreated.firstChild().nodeValue();
                         strModified  = qNodemodified.firstChild().nodeValue();
                         strOwner = qNodeowner.firstChild().nodeValue();
                         strUrl  = qNodeurl.firstChild().nodeValue();
                         strThumbnailUrl = qNodethumbnailUrl.firstChild().nodeValue();
                         strSize  = qNodesize.firstChild().nodeValue();
                         strIsActive = qNodeIsActive.firstChild().nodeValue();
                         strEntryDate  = qNodeEntryDate.firstChild().nodeValue();
    
                   }
               }
    

    Edit: Added code tags - p3c0

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Mathan-M Instead of QDom* you can use the QXmlStreamReader as the document says it is quite faster and memory efficient.
      Once you get to the parent node you can just use name and readElementText iteratively.

      157

      1 Reply Last reply
      4

      • Login

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