{
::CoInitialize(NULL);
IXMLDOMDocumentPtr domDocument;
HRESULT hr = domDocument.CreateInstance(CLSID_DOMDocument);
if (FAILED(hr))
{
_com_error er(hr);
AfxMessageBox(er.ErrorMessage());
}
CString strFileName ="C:\test.xml";
CComBSTR bstrFileName(strFileName);
VARIANT_BOOL vStatus = VARIANT_FALSE;
CComVariant name(strFileName);
hr = domDocument->load(name, &vStatus);
if (FAILED(hr))
{
int errorCode = ::GetLastError();
AfxMessageBox("Load XML failed!");
return ;
}
CComPtr
long l_CountZone;
long l_CountPage;
_bstr_t TPage = "Page";
hr = domDocument->getElementsByTagName(TPage,&xnlPage);
if (FAILED(hr))
{
int errorCode = ::GetLastError();
AfxMessageBox("get_firstChild failed!");
return ;
}
hr = xnlPage->get_length(&l_CountPage);
for(int iCountPage= m_CurrPageNum-1;iCountPage<l_CountPage; iCountPage++)
{
CComPtr
hr = xnlPage->get_item(iCountPage,&xnPage);
CComPtr
hr = xnPage->selectNodes(_bstr_t("Zone"),&xnlZone);
hr = xnlZone->get_length(&l_CountZone);
for(int iCountZone= 0;iCountZone<l_CountZone; iCountZone++)
{
CComPtr
CComPtr
hr = xnlZone->get_item(iCountZone,&xnZone);
xnZone->get_parentNode(&xnZoneParent);
xnZoneParent->removeChild(xnZone,&pXMLNodeOld);
xnZone.Release();
xnZone=NULL;
xnZoneParent.Release();
xnZoneParent=NULL;
}
xnlZone.Release();
xnlZone=NULL;
}
xnlPage.Release();
xnlPage=NULL;
domDocument->save(name);
domDocument.Release();
domDocument=NULL;
::CoUninitialize();
}
1 comment:
I enjoy reading through an article that can make people think.
Also, thank you for allowing me to comment! payday
loan
My webpage: instant payday loans
Post a Comment