CMarkup FindChildElem return 0

来源:互联网 发布:网络录像机安装教程 编辑:程序博客网 时间:2024/06/06 01:09
    1. CMarkup xml;   
    2. xml.Load(str);   
    3. xml.ResetMainPos();   
    4. if(xml.FindChildElem("device"))   
    5. {       
    6.     xml.IntoElem();   
    7.         
    8.     xml.FindChildElem("DeviceStatus");//return 1;
    9.     str=xml.GetChildData();
    10.         if(atoi(str) == 1)
    11.     {
    12.             xml.FindChildElem("DeviceName");//return 0;
    13.         }
    14. }

 

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <devices>
  3. <device>
  4. <DeviceName>51</DeviceName>
  5. <DeviceIP>192.168.0.51</DeviceIP>
  6. <DevicePort>6666</DevicePort>
  7. <DeviceType>1</DeviceType>
  8. <DevicePhase>0</DevicePhase>
  9. <LocalDevice>0</LocalDevice>
  10. <NextDevice>0</NextDevice>
  11. <DevicePriority>0</DevicePriority>
  12. <DeviceStatus>1</DeviceStatus>
  13. </device>
  14. </devices>

 

DeviceStatus用于判断,程序不能这样写,FindChildElem直接查找后面的文段,所以返回为0,

以上有2中解决办法,一种是调整<DeviceStatus></DeviceStatus>的位置,另一种是先依次保存信息,然后再判断,不知道这样理解可不可以

 

 

 

原创粉丝点击