?
Solved

Save String to XML File

Posted on 2005-05-07
5
Medium Priority
?
178 Views
Last Modified: 2010-04-07
I have a webservice that expects a XML as a string, before the webservices does anything i would like tot save the string as an XML and save on the server, incase needed later on.

how can this be done.
0
Comment
Question by:dkilby
2 Comments
 
LVL 26

Accepted Solution

by:
Rejojohny earned 1000 total points
ID: 13953090
imports system.xml

write his code this within ur web service method ...

         Dim doc As XmlDocument = New XmlDocument()
         doc.LoadXml(UrXMLStringParmater)

         ' Save the XML to a file.
         doc.Save(FileName.xml) '.... give the full path where u would like to save it .. this code will save it to the current directory ...
0
 
LVL 23

Assisted Solution

by:b1xml2
b1xml2 earned 1000 total points
ID: 13953435
To write a string to a file,
[VB.NET]
Dim writer As New System.IO.StreamWriter("c:\data.xml",False,System.Text.Encoding.UTF8)
writer.Write(text)
writer.Flush()
writer.Close()

[C#]
System.IO.StreamWriter writer = new System.IO.StreamWriter(@"c:\data.xml",false, System.Text.Encoding.UTF8);
writer.Write(text);
writer.Flush();
writer.Close();

If you want to validate the Xml, then using the XmlDocument would be an easy way. If you are already using the XmlDocument then you just save as Rejo as indicated. If you do not want to validate the nodes for whatever reason and are not using the XmlDocument and want performance (Web Services can be slow at times), then the simple use of the StreamWriter will just write your string into the file.


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question