笔记之用
CMarkupSTL 版本:Release 7.3
读:
void read_xml() { char sMsg[126]; xml.Load(xmlName); if(!xml.FindElem("root")) { sprintf(sMsg, "find fail %s",xml.GetError().c_str()); return ; } xml.IntoElem(); xml.FindElem("sub_short_forcast"); xml.IntoElem(); while(xml.FindElem("tag")) { xml.FindElem("sub_short_forcast"); string str = xml.GetAttrib("PARES_START_TIME"); cout<<str<<endl; } }
写:
void write_xml() { CMarkupSTL xml; xml.SetDoc("<?xml version=\"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"); }
时间: 2024-10-11 13:42:16