首页 | 本学科首页   官方微博 | 高级检索  
     检索      

基于QT的XML文件自动转换方法
引用本文:王宏明,林卫永,王泉荣,温业中.基于QT的XML文件自动转换方法[J].铁路通信信号工程技术,2021(2).
作者姓名:王宏明  林卫永  王泉荣  温业中
作者单位:通号万全信号设备有限公司
摘    要:为简单方便的将XML文件转换为C++的对象实例,提出一种将XML文件和C++对象之间互相转换的方法。研究XML文件的结构和Q T的元类型系统,以XML根节点为开始,采用深度优先读取算法遍历XML文件的每个节点,将节点内容和节点属性组装到C++对象实例,保留XML文件的元素间的嵌套关系,可以根据该关系读取整个XML文档,也可以根据需要只读取对应节点的内容。最后通过实例验证该方法的正确性和有效性,演示该方法的简单、高效。

关 键 词:可扩展标记语言  XML  QT  转换    C++  动态实例  元类型系统

QT-based Automatic Conversion Method of XML Files
Wang Hongming,Lin Weiyong,Wang Quanrong,Wen Yezhong.QT-based Automatic Conversion Method of XML Files[J].Railway Signalling & Communication Engineering,2021(2).
Authors:Wang Hongming  Lin Weiyong  Wang Quanrong  Wen Yezhong
Institution:(CRSC Wanquan Signal Equipment Co.,Ltd.,Hangzhou 310000,China)
Abstract:In order to convert XML files into object instances of C++,this paper presents an interconversion method between XML files and C++objects.The structure of XML file and the metatype system of QT are studied.Starting with the XML root node,each node of XML file is traversed by depth-fi rst reading algorithm.The content and attributes of node are assembled into C++object instances.The nested relationship among elements of XML fi le is preserved.The whole XML fi le can be read according to this relationship,or only the content of the corresponding node can be read as needed.Finally,an example is given to verify the correctness and validity of the method and demonstrate its simplicity and effi ciency.
Keywords:extensible markup language  XML  QT  conversion  class  C++  dynamic instance  metatype system
本文献已被 维普 等数据库收录!
设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号