xml文件的读取

来源:互联网 发布:网络舆情应对 编辑:程序博客网 时间:2024/05/18 00:10

“ofxxmlsetting.h”

ofxxmlsettings xml= new  ofxxmlsettings;

bool r = xml.loadFile("配置文件.xml");

string str

if(r)

{xml.pushTag("root");

xml.pushTag("device_type");

xml.pushTag(type);

xml.getvalue(cmd,"");

xml.popTag();

xml.popTag();

xml.popTag();

}

reture str;

type:是“kb”;

cmd:是“close”

xml文件如下

<root>

   <host>dhhh</host>

   <device_type>

       <kb>

           <close>0001</close>

            <open>00003</open>

      </kb>

       <kb>

           <close>0001</close>

            <open>00003</open>

      </kb>

 

   </device_type>

</root>

“ofxxmlsetting.h”

ofxxmlsettings xml= new  ofxxmlsettings;

bool r = xml.loadFile("配置文件.xml");

if(r)

{  host= xml.getvalue("root:host",host);}

 

原创粉丝点击