xml读取节点
<?xml version="1.0" encoding="utf-8"?>
<tplcd type="" product="JAZZ">
<lcd_specification>
<DefaultPicture>jazz_default.bmp</DefaultPicture>
<!--video or command -->
<PanelMode>command</PanelMode>
<PanelWidth></PanelWidth>
<PanelHeight></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.\n"; }
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, );//str类型转ulong
}
if (!strncmp(lllm->Value(), "PanelHeight", strlen("PanelHeight")))
{
Lcd_Specification.PanelHeight = strtoul(lllm->GetText(), NULL, );//str类型转ulong
}
if (!strncmp(lllm->Value(), "PanelMode", strlen("PanelMode")))
{
if (!strncmp(lllm->GetText(), "command", strlen("command")))
{
Lcd_Specification.PanelMode = ;//
}
else if (!strncmp(lllm->GetText(), "video", strlen("video")))
{
Lcd_Specification.PanelMode = ;//
} }
if (!strncmp(lllm->Value(), "HPulseWidth", strlen("HPulseWidth")))
{
Lcd_Specification.HPulseWidth = strtoul(lllm->GetText(), NULL, );//str类型转ulong
}
if (!strncmp(lllm->Value(), "HBackPorch", strlen("HBackPorch")))
{
Lcd_Specification.HBackPorch = strtoul(lllm->GetText(), NULL, );//str类型转ulong
}
if (!strncmp(lllm->Value(), "HFrontPorch", strlen("HFrontPorch")))
{
Lcd_Specification.HFrontPorch = strtoul(lllm->GetText(), NULL, );//str类型转ulong
} if (!strncmp(lllm->Value(), "VPulseWidth", strlen("VPulseWidth")))
{
Lcd_Specification.VPulseWidth = strtoul(lllm->GetText(), NULL, );//str类型转ulong
}
if (!strncmp(lllm->Value(), "VBackPorch", strlen("VBackPorch")))
{
Lcd_Specification.VBackPorch = strtoul(lllm->GetText(), NULL, );//str类型转ulong
}
if (!strncmp(lllm->Value(), "VFrontPorch", strlen("VFrontPorch")))
{
Lcd_Specification.VFrontPorch = strtoul(lllm->GetText(), NULL, );//str类型转ulong
}
if (!strncmp(lllm->Value(), "PWMMode", strlen("PWMMode")))
{
Lcd_Specification.PWMMode = strtoul(lllm->GetText(), NULL, );//str类型转ulong
}
if (!strncmp(lllm->Value(), "ColorOrder", strlen("ColorOrder")))
{
if (!strncmp(lllm->GetText(), "BGR", strlen("ColorOrder")))
{
Lcd_Specification.ColorOrder = ;
}
else if (!strncmp(lllm->GetText(), "RGB", strlen("ColorOrder")))
{
Lcd_Specification.ColorOrder = ;
} }
if (!strncmp(lllm->Value(), "DPhyNum", strlen("DPhyNum")))
{
Lcd_Specification.DPhyNum = strtoul(lllm->GetText(), NULL, );//str类型转ulong
} }
附上经典历程网址http://www.cnblogs.com/ziwuge/archive/2011/08/10/2133534.html
这个温度也很不错http://wenku.baidu.com/link?url=9zPLXHr1PzX3I5oYeCizHe1jTbLqaeL13OTou0YIMaEKtPrwXcnyNIqOcOc2pCqV2SfikG4K8KyYu76x7bxttmakqsrbDaQMT9hrCjCnrTO
xml读取节点的更多相关文章
- C#使用Linq To XML读取XML,Linq生成XML,Linq创建带属性或带节点XML
using System; using System.Linq; using System.Xml.Linq; namespace Sample2 { class Program { static v ...
- javascript读取xml文件读取节点数据的例子
分享下用javascript读取xml文件读取节点数据方法. 读取的节点数据,还有一种情况是读取节点属性数据. <head> <title></title> < ...
- VB 老旧版本维护系列---读取xml某个节点的值
读取xml某个节点的值 '定义xml字符串内容地址 Dim xmlFileStr As String = "" '定义所需读取节点的名称 Dim readNodeName As S ...
- TreeView 读取 xml 显示节点
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Tree2_xml.aspx.c ...
- Linq to XML 读取XML 备忘笔记
本文转载:http://www.cnblogs.com/infozero/archive/2010/07/13/1776383.html Linq to XML 读取XML 备忘笔记 最近一个项目中有 ...
- 根据XPATH去查看修改xml文件节点的内容
首先给出xml文件解析的路径,然后去读取节点的内容. package com.inetpsa.eqc.threads; import java.util.List; import java.io.Fi ...
- C#基础笔记---浅谈XML读取以及简单的ORM实现
背景: 在开发ASP.NETMVC4 项目中,虽然web.config配置满足了大部分需求,不过对于某些特定业务,我们有时候需要添加新的配置文件来记录配置信息,那么XML文件配置无疑是我们选择的一个方 ...
- XML记一次带命名空间的xml读取
public static void ReadXML(string xmlUrl) { //判断文件是否存在 if (!File.Exists(xmlUrl)) { Console.WriteLine ...
- C# xml 读xml、写xml、Xpath、Xml to Linq、xml添加节点 xml修改节点
#region XDocument //创建XDocument XDocument xdoc2 = new XDocument(); XElement xel1= new XElement(" ...
随机推荐
- [LeetCode] Contains Duplicate III 包含重复值之三
Given an array of integers, find out whether there are two distinct indices i and j in the array suc ...
- 【C#】安装windows服务
参考:http://blog.csdn.net ,http://blog.csdn.net/dyzcode 1.新建 visual studio insaller 项目2.添加 [文件系统]3.添加 ...
- PRINCE2特征(三)
提到不确定性,可能很多从事项目管理相关工作的人都会感同身受,一系列临时性问题,比如:变更.延期.调整.计划赶不上变化.团队调整等的出现,都是项目中再正常不过的内容.但正常不等于合理,我们还是要去思考一 ...
- UIDynamic--动力元素行为:UIDynamicItemBehavior
属性分析: @property (nonatomic, readonly, copy) NSArray* items; @property (readwrite, nonatomic) CGFloat ...
- 日历插件FullCalendar应用:(二)数据增删改
接上一篇 日历插件FullCalendar应用:(一)数据展现. 这一篇主要讲使用fullcalendar插件如何做数据的增删改,用到了art.dialog web对话框组件,上一篇用到的webFor ...
- android GPS定位源码 地图显示位置源码 有用到的小伙伴自提取
package com.jasgroup.cn.amhdeam; import java.io.IOException; import java.util.Iterator; import andro ...
- 史上最详细的linux网卡ifcfg-eth0配置详解
通过查资料与工作中的进行一下总结: DEVICE="eth1" 网卡名称NM_CONTROLLED="yes" network mamager的参 ...
- Windows常用快捷方式
总结了其他常用的快捷方式: Ctrl+C 复制 . Ctrl+V粘贴. Ctrl+X剪切. Delete删除. Alt+Tab 应用程序切换 Ctrl+Alt+Delete Ctrl+shift+E ...
- canvas刮刮乐效果(pc端&H5、zepto-touchmove)
一.html <div id="canvasArea" style="width:300px;height:200px;position:relative;&quo ...
- 报错:emulator: WARNING: ./android/metrics/metrics_reporter_toolbar.cpp:167: Can't upload usage metrics: Error