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] Remove Nth Node From End of List 移除链表倒数第N个节点
Given a linked list, remove the nth node from the end of list and return its head. For example, Give ...
- 使用EXtjs6.2构建web项目
一.项目简介 众所周知ext是一款非常强大的表格控件,尤其是里边的grid为用户提供了非常多的功能,现在主流的还是用extjs4.0-4.2,但是更高一点的版本更加符合人的审美要求.因此,在今天咱们构 ...
- 关于若干php 表单 的重新审视
对于表单验证来说 应该在任何可能的时候对用户输入进行验证(通过客户端脚本).浏览器验证速度更快,并且可以减轻服务器的负载. 如果用户输入需要插入数据库,您应该考虑使用服务器验证.在服务器验证表单的一种 ...
- php 设计模式--准备篇
要了解设计模式 首先我们要先了解 php的命名空间和类的自动载入的功能 下面我们来说一下 命名空间 概念缘由:比如一个a.php的文章 但是我们需要两个 此时同一个目录下不可能存在两个a.php 那么 ...
- windows多线程编程
进程共同实现某个任务或者共享计算机资源, 它们之间存在两种关系: 1.同步关系, 指为了完成任务的进程之间, 因为需要在某些位置协调它们的执行顺序而等待, 传递消息产生的制约关系. 2.互斥关系, 进 ...
- git提示:Fatal:could not fetch refs from ....
在git服务器上新建项目提示: Fatal:could not fetch refs from git..... 百度搜索毫无头绪,最后FQgoogle,找到这篇文章http://www.voidcn ...
- intellij idea 12 编码不可映射字符
IntelliJ IDEA中错误提示:java: Syntax error on token "Invalid Character", delete this token Inte ...
- oracle新建登录用户sql语句
CREATE TABLESPACE TEST_DBDATAFILE '/mnt/data/oracledata/TEST_DB .dbf' SIZE 5000M AUTOEXTEND ONUNIFOR ...
- 【转】MipMap
原文地址http://www.cppblog.com/wc250en007/archive/2011/08/06/152653.html 首先从MIPMAP的原理说起,它是把一张贴图按照2的倍数进行缩 ...
- Java分页需求
近期在实现项目接口时,经常需要分页功能.有时返回“String”,有时是“Object”格式的分页List.针对这种情况,本人用java实现对List分页. 第一版 package org.sun.j ...