如何通过套接字传递数据的XML? [英] How to pass data as XML via sockets?

查看:251
本文介绍了如何通过套接字传递数据的XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 XML模式写在C / C插座程序之间++的形式交换数据。可能有人请提供链接的教程,它描述插座程序之间交换的XML模式的过程。

I want to exchange data in the form of XML schema between socket programs written in C/C++. Could someone please provide links tutorials which describe the process of exchanging XML schema between socket programs.

我在不同的操作系统上运行的两个软件工具,我在其中加上写在C / C ++ socket编程。正如 XML 都工作,我想知道是否有在XML文档的形式来运行模拟研究交换数据的简单方法。

I have two software tools running in different Operating Systems, in which I coupled with socket programs written in c/c++. As both work with XML, I want to know if there is a simple way to exchange data in the form of XML documents in order to run simulation studies.

先谢谢了。

问题是如何通过用C / C ++套接字程序发送XML模式?这里有一个经验值:

the question is how to send xml schema through a socket program written in C/C++ ? here is an exp:

----- XML​​ ---结果
...结果
< XS:元素的名称=区> 结果
< XS:复杂类型> 结果
< XS:序列> 结果
< XS:元素的名称=VAR_NAME类型=XS:字符串/> 结果
< XS:元素的名称=var_value类型=XS:十进制/> 结果
< / XS:序列> 结果
< / XS:复杂类型> 结果
< / XS:组件>

----- xml ---
...
<xs:element name="zone">
<xs:complexType>
<xs:sequence>
<xs:element name="Var_name" type="xs:string"/>
<xs:element name="var_value" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
</xs:element>

------ C / C ++ ----结果
...结果
//将消息发送到服务器的结果
如果(发送(CSocket类,buffer_snd,BUFSIZE,0)> BUFSIZE)结果
COUT&LT;&LT;发送()失败&LT;&LT; ENDL;结果
...

------ C/C++ ----
...
// send message to server
if (send(csocket, buffer_snd, BUFSIZE, 0) > BUFSIZE)
cout << send() failed << endl;
...

请多关照您的帮助,

推荐答案

看来你想要的是在XML Schema中,然后,将让您解析和序列化XML消息自动生成C ++类来指定协议。如果是这样,那么你可能想看看 codeSynthesis XSD 这是一个XML Schema到C ++编译器。它确实pretty多,你正在寻找什么。如果你想要一个更更轻的版本,也有XSD / E这是更适合于移动/嵌入式开发。

It seems what you want is to specify your protocol in XML Schema and then auto-generate C++ classes that would allow you to parse and serialize the XML messages. If so then you may want to take a look at CodeSynthesis XSD which is an XML Schema to C++ compiler. It does pretty much exactly what you are looking for. If you want a more lighter-weight version, there is also XSD/e which is geared more towards mobile/embedded development.

这篇关于如何通过套接字传递数据的XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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