Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Deleting data from XML

Deleting data from XML

Scheduled Pinned Locked Moved C / C++ / MFC
xmltutorialquestion
7 Posts 4 Posters 0 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.
  • B Offline
    B Offline
    brucewayn
    wrote on last edited by
    #1

    I'm working on an application where i have a requirement to delete the XML data which is between certain dates. However i was able to get the data within those particular dates given by the user but i have no idea how to delete them. Please let me know if there is any function ??? I even used removechild function but the application is getting crashed.

    S C 3 Replies Last reply
    0
    • B brucewayn

      I'm working on an application where i have a requirement to delete the XML data which is between certain dates. However i was able to get the data within those particular dates given by the user but i have no idea how to delete them. Please let me know if there is any function ??? I even used removechild function but the application is getting crashed.

      S Offline
      S Offline
      sam_psycho
      wrote on last edited by
      #2

      will you show the code to delete required node? :)

      1 Reply Last reply
      0
      • B brucewayn

        I'm working on an application where i have a requirement to delete the XML data which is between certain dates. However i was able to get the data within those particular dates given by the user but i have no idea how to delete them. Please let me know if there is any function ??? I even used removechild function but the application is getting crashed.

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        brucewayn wrote:

        I'm working on an application where i have a requirement to delete the XML data which is between certain dates. However i was able to get the data within those particular dates given by the user but i have no idea how to delete them.

        You mean a xml file, right ? If that's the case you have to rewrite the full file without the data you want to delete. Now, how to do it really depends on what you are using to read the xml file. In general most of the libraries allow you to also write xml back to a file.

        brucewayn wrote:

        I even used removechild function but the application is getting crashed

        removechild ? Where's that coming from ? I guess it is coming from a specific library but it would help a lot if you provide information about what you are using.

        Cédric Moonen Software developer
        Charting control [v1.5] OpenGL game tutorial in C++

        1 Reply Last reply
        0
        • B brucewayn

          I'm working on an application where i have a requirement to delete the XML data which is between certain dates. However i was able to get the data within those particular dates given by the user but i have no idea how to delete them. Please let me know if there is any function ??? I even used removechild function but the application is getting crashed.

          S Offline
          S Offline
          sam_psycho
          wrote on last edited by
          #4

          I am giving you idea to delete data from xml, it will be useful to you :thumbsup: MSXML2::IXMLDOMNodeListPtr pNodeList1 = ePtrRootXML->selectNodes("//parentOfDatenode"); while(MSXML2::IXMLDOMNodePtr pTemp = pNodeList1->nextNode()) { if(pTemp) { // if date is given by user no need MSXML2::IXMLDOMNodePtr pFromDate = pTemp->selectSingleNode(".//fromdate"); MSXML2::IXMLDOMNodePtr pToDate = pTemp->selectSingleNode(".//todate"); strFromDate = (LPCTSTR)pFromDate->text; strToDate =(LPCTSTR)pToDate->text; OleDateTime olecurrentdate(COleDateTime::GetCurrentTime()); // convert strFromDate and strToDate to OleDateTime format n compare if( olecurrentdate<=oleTodate) // delete if success { pSection->removeChild(pTemp); DocptrXML->save(bstrOutputXML);//bstrOutputXML= XML name with full path } }

          C 1 Reply Last reply
          0
          • S sam_psycho

            I am giving you idea to delete data from xml, it will be useful to you :thumbsup: MSXML2::IXMLDOMNodeListPtr pNodeList1 = ePtrRootXML->selectNodes("//parentOfDatenode"); while(MSXML2::IXMLDOMNodePtr pTemp = pNodeList1->nextNode()) { if(pTemp) { // if date is given by user no need MSXML2::IXMLDOMNodePtr pFromDate = pTemp->selectSingleNode(".//fromdate"); MSXML2::IXMLDOMNodePtr pToDate = pTemp->selectSingleNode(".//todate"); strFromDate = (LPCTSTR)pFromDate->text; strToDate =(LPCTSTR)pToDate->text; OleDateTime olecurrentdate(COleDateTime::GetCurrentTime()); // convert strFromDate and strToDate to OleDateTime format n compare if( olecurrentdate<=oleTodate) // delete if success { pSection->removeChild(pTemp); DocptrXML->save(bstrOutputXML);//bstrOutputXML= XML name with full path } }

            C Offline
            C Offline
            Cedric Moonen
            wrote on last edited by
            #5

            You said your application crashes, did you use your debugger to see where the problem occurs exactly ? Without using your debugger, you won't be able to go very far...

            Cédric Moonen Software developer
            Charting control [v1.5] OpenGL game tutorial in C++

            C 1 Reply Last reply
            0
            • C Cedric Moonen

              You said your application crashes, did you use your debugger to see where the problem occurs exactly ? Without using your debugger, you won't be able to go very far...

              Cédric Moonen Software developer
              Charting control [v1.5] OpenGL game tutorial in C++

              C Offline
              C Offline
              CPallini
              wrote on last edited by
              #6

              I suppose you replied to the wrong post (unsless Sam today is so crazy to call himsel Bruce :rolleyes: ). :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              C 1 Reply Last reply
              0
              • C CPallini

                I suppose you replied to the wrong post (unsless Sam today is so crazy to call himsel Bruce :rolleyes: ). :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                C Offline
                C Offline
                Cedric Moonen
                wrote on last edited by
                #7

                Oh yes, I mixed the different posts... I guess it was too early in the morning ;)

                Cédric Moonen Software developer
                Charting control [v1.5] OpenGL game tutorial in C++

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups