Connecting Tech Pros Worldwide Help | Site Map

Converting XML to byte[]

  #1  
Old January 8th, 2009, 11:05 PM
Newbie
 
Join Date: Dec 2008
Posts: 10
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

Last edited by Dormilich; January 8th, 2009 at 11:09 PM. Reason: added [code] tags
  #2  
Old January 8th, 2009, 11:14 PM
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,487
Provided Answers: 9

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.
  #3  
Old January 9th, 2009, 06:12 AM
skitsanos's Avatar
Newbie
 
Join Date: Jan 2009
Location: Bucharest, Romania
Posts: 3

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert XML file data to byte array by FromBase64String passing(string xmlData) BobbyS answers 0 January 30th, 2008 02:46 PM
Converting instances to byte[] Curious answers 2 February 12th, 2006 08:55 AM
Convert Structure to Byte Array Charles Law answers 9 November 20th, 2005 01:23 PM
Converting IntPtr to byte[] Brian Harleton answers 2 November 15th, 2005 07:18 AM