Deleting data from XML
-
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.
-
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.
will you show the code to delete required node? :)
-
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.
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++ -
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.
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 } }
-
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 } }
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++ -
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++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] -
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]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++