Save String to XML File

Posted on 2005-05-07
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.
Question by:dkilby
    LVL 26

    Accepted Solution

    imports system.xml

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

             Dim doc As XmlDocument = New XmlDocument()

             ' 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 ...
    LVL 23

    Assisted Solution

    To write a string to a file,
    Dim writer As New System.IO.StreamWriter("c:\data.xml",False,System.Text.Encoding.UTF8)

    System.IO.StreamWriter writer = new System.IO.StreamWriter(@"c:\data.xml",false, System.Text.Encoding.UTF8);

    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.


    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    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…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now