2012-02-11 14:46:19|?次阅读|上传:wustguangh【已有?条评论】发表评论
关键词:C/C++, XML, 数据库|来源:唯设编程网
5.查找元素
CMarkup xml; BOOL bLoad = false; BOOL bFind = false; bLoad = xml.Load("UserInfo1.xml"); if (bLoad) { CString strID; CString strPwd; xml.ResetMainPos(); xml.FindElem(); //UserInfo while (xml.FindChildElem("User")) { strID = xml.GetChildAttrib("UserID"); strPwd = xml.GetChildAttrib("UserPwd"); TRACE(" ----id:%s,pwd:%s------- ",strID,strPwd); if (strID=="UserID00"&&strPwd=="UserPwd00") { bFind = true; break; } } } if (bFind) { TRACE(" ---- find------ "); } else { TRACE(" ----no find------ "); }
6.修改元素
CMarkup xml; BOOL bLoad = false; BOOL bFind = false; bLoad = xml.Load("UserInfo1.xml"); if (bLoad) { CString strID; CString strPwd; xml.ResetMainPos(); xml.FindElem(); //UserInfo while (xml.FindChildElem("User")) { strID = xml.GetChildAttrib("UserID"); strPwd = xml.GetChildAttrib("UserPwd"); TRACE(" ----id:%s,pwd:%s------- ",strID,strPwd); if (strID=="UserID00"&&strPwd=="UserPwd00") { bFind = true; xml.SetChildAttrib("UserID",strID+CString("Modify")); xml.Save("UserInfo1.xml"); break; } } } if (bFind) { TRACE(" ---- find------ "); } else { TRACE(" ----no find------ "); }