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] Rank Scores 分数排行
Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ...
- Alpha阶段总结
Alpha阶段的验收已经完成,8个小组都展现了他们经过连夜奋战后的成果.相比过往几届,这是第一次8个小组全部顺利演示操作完成,没有个别小组因为任务未完成而延宕演示的情况发生.Alpha演示,各组都实现 ...
- 函数:MySQL中字符串匹配函数LOCATE和POSITION使用方法
1. 用法一 LOCATE(substr,str) POSITION(substr IN str) 函数返回子串substr在字符串str中第一次出现的位置.如果子串substr在str中不存在,返回 ...
- openssl+前端jsrsa签名+后端nodejs验签
内容如标题所示,总体分为三个部分: 一.win10下安装openssl,然后通过openssl工具生成RSA的公钥和私钥 (1)win10下安装openssl需要的工具有:VS2013,Perl,na ...
- LoadRunner安装+汉化+破解
因为工作需要要用到LoadRunner,找个好几个版本,换了两台电脑(公司的win7折腾了好久装不上去),耗时两天终于搞定了,分享给需要的小伙伴们,避免大家踩更多的坑~ 一.安装前的准备 Win10系 ...
- JavaScript工具代码
html编码 function htmlEscape(sHtml){ return sHtml && sHtml.replace(/[<>&"]/g, f ...
- 【JavaWeb】Spring+SpringMVC+MyBatis+SpringSecurity+EhCache+JCaptcha 完整Web基础框架(二)
Log4j 这个东西,大家都熟悉,就简单的介绍一下,算是一个抛砖引玉,因为我自己在Log日志的搭建方面,没有什么经验,但这东西确实是非常重要的,日后调Bug没有它基本不可能,如果有朋友有什么比较好的L ...
- Nodejs事件引擎libuv源码剖析之:请求(request)结构的设计剖析
声明:本文为原创博文,转载请注明出处. 在libuv中,请求(request)代表一个用户向libuv发出的指令,比如uv_connect_s就表示一个tcp的连接请求.uv_work ...
- vim + ctags + taglist配置和使用
vim +ctags + taglist ,ctags+cscope 安装配置和使用 内容:VIM下ctags和taglist的安装配置方法:一键安装 ctags和cscope的方法 :vim语法高亮 ...
- 用Canvas实现动画效果
1.清除Canvas的内容 clearRect(x,y,width,height)函数用于清除图像中指定矩形区域的内容 <!doctype html> <html> <h ...