VC中使用CMarkup类操作XML
时间:2010-07-15 来源:yf956613
//----------UserInfo.xml--------------
<?xml version="1.0" encoding="UTF-8" ?>
<UserInfo>
<UserID>luo</UserID>
<UserID>lin</UserID>
</UserInfo>
1。生成UserInfo.xml
CMarkup xml;
xml.SetDoc("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
xml.AddElem("UserInfo");
xml.IntoElem();
xml.AddElem("UserID","luo");
xml.AddElem("UserID","lin");
xml.OutOfElem();
xml.Save("UserInfo.xml");
2。浏览特定元素
//----查看所有UserID----
CMarkup xml;
xml.Load("UserInfo.xml");
BOOL bFind = true;
xml.ResetMainPos();
while (xml.FindChildElem("UserID");)
{
<?xml version="1.0" encoding="UTF-8" ?>
<UserInfo>
<UserID>luo</UserID>
<UserID>lin</UserID>
</UserInfo>
1。生成UserInfo.xml
CMarkup xml;
xml.SetDoc("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
xml.AddElem("UserInfo");
xml.IntoElem();
xml.AddElem("UserID","luo");
xml.AddElem("UserID","lin");
xml.OutOfElem();
xml.Save("UserInfo.xml");
2。浏览特定元素
//----查看所有UserID----
CMarkup xml;
xml.Load("UserInfo.xml");
BOOL bFind = true;
xml.ResetMainPos();
while (xml.FindChildElem("UserID");)
{
相关阅读 更多 +