Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Converting XML to String

Tags: string

In this short post I will show you how to convert XML to String, o viceversa, in order for example, to send it via Tcp/Ip.


In this example, a Client is going to genereta a XML Document and convert it to string.

The Server side must recive the string and generate the XML.

(Here you will not see how the communication is done, for example the convertion between string and stream)


Client Code:


XmlDocument xmlDoc = new XmlDocument();

xmlDoc.Load(@"C:\XML\" + test + ".xml");


//Getting the Xml as String

String message = xmlDoc.InnerXml;

client.Send(message);


Server Code:


String innerXml = response;

XmlDocument xmlServer = new XmlDocument();


//Set the string to the Xml created above

xmlServer.InnerXml = innerXml;



This post first appeared on Practical C# Codes, please read the originial post: here

Share the post

Converting XML to String

×

Subscribe to Practical C# Codes

Get updates delivered right to your inbox!

Thank you for your subscription

×