笔记之用
CMarkupSTL 版本:Release 7.3
读:
voidread_xml() { charsMsg[126]; xml.Load(xmlName); if(!xml.FindElem("root")) { sprintf(sMsg,"findfail%s",xml.GetError().c_str()); return; } xml.IntoElem(); xml.FindElem("sub_short_forcast"); xml.IntoElem(); while(xml.FindElem("tag")) { xml.FindElem("sub_short_forcast"); stringstr=xml.GetAttrib("PARES_START_TIME"); cout<<str<<endl; } }
写:
voidwrite_xml() { CMarkupSTLxml; xml.SetDoc("<?xmlversion=\"1.0\"encoding=\"UTF-8\"?>\r\n"); xml.AddElem("root"); xml.AddChildElem("sub_short_forcast"); xml.IntoElem(); xml.AddChildElem("tag"); xml.IntoElem(); xml.SetAttrib("name","zhangfei"); xml.SetAttrib("age","40"); //xml.OutOfElem(); xml.Save("./a.xml"); }