Connecting Tech Pros Worldwide Forums | Help | Site Map

Converting XML to byte[]

Newbie
 
Join Date: Dec 2008
Posts: 10
#1: Jan 8 '09
Hi,

I'm writing XML simulator that suppose to be a black box.
Loads xml messages, transforms them into byte[] and sends to the other application via TCP/IP protocol without knowing how the application on the other side is implemented.

I need to convert XML message to byte[] and send it via TCP/IP,
but I can't use serialization, because nobody will do the desirialize on the other side(TCP/IP).
Is there any other way?
I have the xsd.

Example of such xml:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <Msg xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="msg.xsd">
  3.    <header>
  4.      <id>7</id>
  5.      <source_address>127.0.0.1</source_address>
  6.    </header>
  7.    <body>
  8.      <location>North</location>
  9.      <report_time>
  10.        <day_of_month>20</day_of_month>
  11.      </report_time>
  12.    </body>
  13. </Msg>
Thanks

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,654
#2: Jan 8 '09

re: Converting XML to byte[]


Quote:

Originally Posted by maya7 View Post

I need to convert XML message to byte[] and send it via TCP/IP, ...

what do you mean by "byte[]"?

regards

after reading the C# thread, it would probably be the best if you know what the message shall look like and use (e.g.) XSLT to convert it to that format.
skitsanos's Avatar
Newbie
 
Join Date: Jan 2009
Location: Bucharest, Romania
Posts: 3
#3: Jan 9 '09

re: Converting XML to byte[]


you can do XML to C# (or VB.NET) "translation" with XSLT, where you generate language code out of your XML message and then you can perform runt-time compilation and execution of your dynamically generated "assembly". pretty easy to do actually.
Reply