how to construct xml structure
来源:互联网 发布:js事件委托得到索引 编辑:程序博客网 时间:2024/05/16 07:26
ok,xml has a complex structure,but we also can said xml has a simple structure.so ,the importance thing is how to design.like a this example:
<DocumentElement>
<MTU_NUM>1</MTU_NUM>
<mtuid>5910001</mtuid>
<mtuname>参考名称</mtuname>
<area>设备所属地市</area>
<env>安装的场景</env>
<inuse>0</inuse>
<sim_info simcard_capa=”3”>
<sim_card>
<imsi>460029731032920</imsi>
<msisdn>1385910000</msisdn>
</sim_card>
<sim_card>
<imsi></imsi>
<msisdn></msisdn>
</sim_card>
<sim_card>
<imsi>460029731032921</imsi>
<msisdn>1385910001</msisdn>
</sim_card>
</sim_info>
<coordinate>
<lon>120.0001</lon>
<lat>60.0002</lat>
</coordinate>
<sensor_info num_of_sensor=”8”>
<sensor_name>传感器1名称</sensor_name>
<sensor_name></sensor_name>
<sensor_name>传感器3名称</sensor_name>
<sensor_name>传感器4名称</sensor_name>
<sensor_name></sensor_name>
<sensor_name></sensor_name>
<sensor_name></sensor_name>
<sensor_name>传感器8名称</sensor_name>
</sensor_info>
<test_type_capa>
<MOS_UL />
<MOS_DL />
<test_type_capa>
<firm_ware>
<version>01.10</version>
</firm_ware>
</DocumentElement>
how to analyse this code?frist of all ,we should know how much section this code can be devide . this code has two type label.xmlroot is </DocumentElement>,this contain some xmlelement,and some element has their own xmlelement and xmlattribute.
<sensor_info num_of_sensor=”8”>
<sensor_name>传感器1名称</sensor_name>
<sensor_name></sensor_name>
<sensor_name>传感器3名称</sensor_name>
<sensor_name>传感器4名称</sensor_name>
<sensor_name></sensor_name>
<sensor_name></sensor_name>
<sensor_name></sensor_name>
<sensor_name>传感器8名称</sensor_name>
</sensor_info>
num_of_sensor is xmlattribute and sensor_name is xmlelement.
how to describe this layer?i think class is a good method.<DocumentElement> is a class ,and he contain many attribute,some of this is xmlelement,and another is xmlattribute.this attribute may be is just attribute,may be a class contain their own xmlattribute and xmlelement. like <sensor_info>,code just like this:
public class at
{
[xmlelement("sensor_name")]
public string mtuid;
[xmlelement("sensor_name")]
public string mtuname;
[xmlelement("sensor_name")]
public sensor_name newSensorName = new sensor_name;
............................................
}
public class sensor_name
{
[xmlattribute("num_of_sensor")]
public string num_of_sensor;
[xmlelement("sensor_name")]
public list<string> sensorName = new list<string>();
}
so ,we can deal with all type xml structure,and can use method to searlize it.
- how to construct xml structure
- How to construct a DiamondOfNumbers
- How to construct/destruct before/after main()
- How to construct a Hopfield network
- 论文阅读:How to Construct Deep Recurrent Neural Networks
- How to Structure a Scalable And Maintainable Acceptance Test Suite
- How To Use SQL XML ?
- An example to show how to make Tree structure data table in SQL server
- How to convert XML to Android Binary XML
- How to write XML Web Service
- How to import xml data into excel
- How to use Hibernate - XML Configuration
- How-to: parsing XML with Qt
- 怎样构建一个GIT服务器(How to Construct A GIT Server)
- How to Construct Basic Logic Gates from Nand Gate Using Bool Algebra
- How to store a 1D table data into a general data structure?
- Data Structure: How to traversal Binary Tree Iteratively (Preorder, Inorder and Postorder)
- How to: Qualify XML Element and XML Attribute Names
- 游戏引擎列表
- 转:《Effective C#》Item 11:提倡使用foreach语句来进行循环操作
- Tomcat下配置MySQL数据库连接池
- NAT描述
- 年轻人机会比金钱重要
- how to construct xml structure
- CSS2样式表(属性·布局)
- 任我逍遥
- wap提交参数的三种方法
- P2P之UDP穿透NAT的原理与实现
- MTU描述
- 图片新闻切换效果
- Six ways to protect yourself from botnets
- 加密算法介绍