如何通过设计xml文件解析协议数据? [英] How to parse protocol data by design xml file?

查看:99
本文介绍了如何通过设计xml文件解析协议数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过设计xml文件解析协议数据?此xml存储协议中关键字的长度和含义.

我问这个问题是因为我必须设计一个xml文件来存储协议信息(用于数据通信).

例如:每个关键字的长度和该关键字的实际含义.然后,我必须使用xml文件中的信息来解析byte [].
但是我发现.NET中的Xmlreader是仅向前访问(对XML数据),因此当我开始解析工作时,它不能满足我的要求.因此,在使用xml解析数据时,我需要一些建议,也许数据是根据我的自定义协议来自某些硬件的byte [].
在协议解析方面的任何相关经验和任何建议将不胜感激.

非常感谢!

How to parse protocol data by design xml file? This xml stores the length and the meaning of the key word in protocol.

I asked this question because I have to design a xml file to store the information of protocol(used in data communication).

for example:the length of every key word and the real meaning of that key word.Then i must use the infomation in xml file to parse byte[].
But i found Xmlreader in .NET is forward-only access (to XML data), thus it will not meet my requirement when i begin my parse work. So I want some advices in using xml to parse data, maybe the data is byte[] from some hardware according to my customize protocol.
Any related experience in protocol parse and any suggestion will be appreciated.

Thank you very much!

推荐答案

请首先完整阅读XML定义文件.使用节点数据实例化表示内存协议定义的类中的成员值.使用从XML文件构建的类来解析数据.
Read the XML definition file in its entirety first. Use the node data to instantiate member values in a class that represents your in-memory protocol definition. Parse the data using the class that was built from the XML file.


这篇关于如何通过设计xml文件解析协议数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆