sanakkian
sanakkian

Reputation: 299

how to pass xml document as a string to a asp.net webservice

Hi i have the xml document in my asp.net web application . I want to assign the xml document to a string and pass that string to a asp.net webservice. Can anyone able to help me to do this ? Thank you

Upvotes: 0

Views: 2782

Answers (2)

Peyman
Peyman

Reputation: 3138

Try this code:

XmlDocument xml = new XmlDocument();
xml.Load("file1.xml");
string xmlString = xml.OuterXml;

and you can pass the xmlString.

Upvotes: 0

Vano Maisuradze
Vano Maisuradze

Reputation: 5899

May be you need this:

        XmlDocument xmlDoc = new XmlDocument();
        StringWriter stringWriter = new StringWriter();
        XmlTextWriter textWriter = new XmlTextWriter(stringWriter);
        xmlDoc.WriteTo(textWriter);
        string xmlText = stringWriter.ToString();

Upvotes: 1

Related Questions