c# - tcp socket data send in xml packet -


i'm trying send data on tcp socket. thing instead of sending simple char* data need buffer data , make 1 xml packet structure out there , therefore send xml data on network. example have 1 ini file read data corresponding variables. say:

[device data ini]  deviceid = 0042 manufacturer = company name vendorid = 00-291-647 timestamp = 2014-08-13 12:40:11 

now need make xml out of above data below:

<?xml version="1.0" encoding="utf-8"?> <datablock xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema">     <deviceid>0042</device>     <manufacturer>company name</manufacturer>     <vendorid>00-291-647</vendorid>     <timestamp>2014-08-13 12:40:11</timestamp> </datablock> 

and send these whole data char* server. best approach build xml data packet simple char* data structure. code written in c++ , xml parsed @ server side c# code. suggestions or recommendation off great help.

use c++ tokenizer split input/source data in order process each line separately (use \r\n separators). example can use boost::split that. after each line use same technique extract key , value (use = separator character). can put parsed keys , values std::map because you'll need them on next step. last step - format target xml string using parsed data. need iterate through map elements , format result string. can use xml template string placeholders each attribute , replace them parsed values.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -