• xml读取节点


    <?xml version="1.0" encoding="utf-8"?>
    <tplcd type="1" product="JAZZ">
      <lcd_specification>
        <DefaultPicture>jazz_default.bmp</DefaultPicture>
        <!--video or command -->
        <PanelMode>command</PanelMode>
        <PanelWidth>1080</PanelWidth>
        <PanelHeight>1920</PanelHeight>
        <HPulseWidth>0x02</HPulseWidth>
        <HBackPorch>0xF0</HBackPorch>
        <HFrontPorch>0xF0</HFrontPorch>
        <VPulseWidth>0x02</VPulseWidth>
        <VBackPorch>0x10</VBackPorch>
        <VFrontPorch>0x1C</VFrontPorch>
        <!--0x01:board pwr supply  ;  0x02 panel pwr supply; 0x03: advance-->
        <PWMMode>0x02</PWMMode>
        <ColorOrder>BGR</ColorOrder>
        <DPhyNum>0x02</DPhyNum>
      </lcd_specification>
        TiXmlDocument doc(XmlFile);
        bool loadOkay = doc.LoadFile();
    
        if (!loadOkay)
        {
        MessageBox(_T("Could not load file"));    
        exit(EXIT_FAILURE);
        return FALSE;
        }
    
        //    doc.Print( stdout );
        ofstream outFile;
        outFile.open("test.log",ios_base::app);
        if (!outFile.is_open())//
        {
            cout << "open OUTPUT file error";
            cout << "program terminating.
    ";
        
        }
        TiXmlElement* tplcdElement = doc.RootElement();
    
        TiXmlElement *Lcd_specific = tplcdElement->FirstChildElement("lcd_specification");
        if (Lcd_specific==nullptr)
        {
            MessageBox(_T("NO lcd_specification"));
            return FALSE;
        }
    
        
        
        TiXmlElement *lspec = Lcd_specific->FirstChildElement();//子节点
        outFile << lspec->Value() << lspec->GetText() << endl;//略去
    
        TiXmlElement *lllm = lspec->NextSiblingElement();    //
        for (lllm = lspec->NextSiblingElement(); lllm != nullptr; lllm = lllm->NextSiblingElement())//lcd_specification read
        {
    
            outFile << lllm->Value() << " " << lllm->GetText() << endl;
         
            if (!strncmp(lllm->Value(), "PanelWidth", strlen("PanelWidth")))
            {
                Lcd_Specification.PanelWidth = strtoul(lllm->GetText(), NULL, 0);//str类型转ulong
            }
            if (!strncmp(lllm->Value(), "PanelHeight", strlen("PanelHeight")))
            {
                Lcd_Specification.PanelHeight = strtoul(lllm->GetText(), NULL, 0);//str类型转ulong
            }
            if (!strncmp(lllm->Value(), "PanelMode", strlen("PanelMode")))
            {
                if (!strncmp(lllm->GetText(), "command", strlen("command")))
                {
                    Lcd_Specification.PanelMode = 0;// 
                }
                else if (!strncmp(lllm->GetText(), "video", strlen("video")))
                {
                    Lcd_Specification.PanelMode = 1;// 
                }
    
            }
            if (!strncmp(lllm->Value(), "HPulseWidth", strlen("HPulseWidth")))
            {
                Lcd_Specification.HPulseWidth = strtoul(lllm->GetText(), NULL, 0);//str类型转ulong
            }
            if (!strncmp(lllm->Value(), "HBackPorch", strlen("HBackPorch")))
            {
                Lcd_Specification.HBackPorch = strtoul(lllm->GetText(), NULL, 0);//str类型转ulong
            }
            if (!strncmp(lllm->Value(), "HFrontPorch", strlen("HFrontPorch")))
            {
                Lcd_Specification.HFrontPorch = strtoul(lllm->GetText(), NULL, 0);//str类型转ulong
            }
    
            if (!strncmp(lllm->Value(), "VPulseWidth", strlen("VPulseWidth")))
            {
                Lcd_Specification.VPulseWidth = strtoul(lllm->GetText(), NULL, 0);//str类型转ulong
            }
            if (!strncmp(lllm->Value(), "VBackPorch", strlen("VBackPorch")))
            {
                Lcd_Specification.VBackPorch = strtoul(lllm->GetText(), NULL, 0);//str类型转ulong
            }
            if (!strncmp(lllm->Value(), "VFrontPorch", strlen("VFrontPorch")))
            {
                Lcd_Specification.VFrontPorch = strtoul(lllm->GetText(), NULL, 0);//str类型转ulong
            }
            if (!strncmp(lllm->Value(), "PWMMode", strlen("PWMMode")))
            {
                Lcd_Specification.PWMMode = strtoul(lllm->GetText(), NULL, 0);//str类型转ulong
            }
            if (!strncmp(lllm->Value(), "ColorOrder", strlen("ColorOrder")))
            {
                if (!strncmp(lllm->GetText(), "BGR", strlen("ColorOrder")))
                {
                    Lcd_Specification.ColorOrder = 1;
                }
                else if (!strncmp(lllm->GetText(), "RGB", strlen("ColorOrder")))
                {
                    Lcd_Specification.ColorOrder = 0;
                }
    
            }
            if (!strncmp(lllm->Value(), "DPhyNum", strlen("DPhyNum")))
            {
                 Lcd_Specification.DPhyNum = strtoul(lllm->GetText(), NULL, 0);//str类型转ulong
            }
    
        }

     附上经典历程网址http://www.cnblogs.com/ziwuge/archive/2011/08/10/2133534.html

    这个温度也很不错http://wenku.baidu.com/link?url=9zPLXHr1PzX3I5oYeCizHe1jTbLqaeL13OTou0YIMaEKtPrwXcnyNIqOcOc2pCqV2SfikG4K8KyYu76x7bxttmakqsrbDaQMT9hrCjCnrTO

  • 相关阅读:
    【转】详解 ASP.NET异步
    [转]C# Unity使用
    [转载]C# 温故而知新:Stream篇
    [转]SQL Server 2008带字段注释导入Power Designer 9.5
    SOAOffice控件
    【转】javascript 杂谈之哪种写法你更喜欢?
    【转】提搞网站访问速度的可做哪些优化
    用vs.NET创建Windows服务
    利用IIS的404错误将文件重写成目录的简单方法
    【转】寻找成为开发高手的密匙
  • 原文地址:https://www.cnblogs.com/xifengib/p/5897257.html
Copyright © 2020-2023  润新知