#include "stdafx.h" #include "tinystr.h" #include "tinyxml.h" void Parse(TiXmlNode* pNode, int nLevel) { while (pNode) { TiXmlElement * pElement = pNode->ToElement(); bool bIsRemove = false; if (pElement) { if (strcmp (pElement->Value() ,"PictureBox") == 0) { bIsRemove = true; } else { TiXmlNode* pSubNode = pElement->FirstChild(); Parse(pSubNode, ++nLevel); } } pNode = pNode->NextSibling(); if (bIsRemove) { TiXmlElement* pParent = pElement->Parent()->ToElement(); if (pParent) { pParent->RemoveChild(pElement); pElement = NULL; } } } } int _tmain(int argc, _TCHAR* argv[]) { TiXmlDocument doc; doc.LoadFile("F_CAMERA_VIEW.xml"); TiXmlElement *pRoot = doc.FirstChildElement(); Parse(pRoot, 0); doc.SaveFile("F_OTHER.xml"); return 0; }