user1727822
user1727822

Reputation: 121

How to read xml stream using c#?

I am getting xml stream from client application how to parse that stream directly and how to load it to dataset?

[WebInvoke(UriTemplate = "UpdateFile/{id}", Method = "POST")]
       public bool UpdateTestXMLFile(string id, Stream createdText)
       {
 string filenamewithpath = System.Web.HttpContext.Current.Server.MapPath(@"~/files/" + id+".xml");
               System.IO.File.WriteAllBytes(filenamewithpath, Util.ReadFully(createdText));
}

Please tell me ..

Upvotes: 1

Views: 526

Answers (1)

Adil
Adil

Reputation: 148120

You can use DataSet.ReadXml(Stream stream), overloaded method of data set, it takes stream in parameter.

[WebInvoke(UriTemplate = "UpdateFile/{id}", Method = "POST")]
public bool UpdateTestXMLFile(string id, Stream createdText)
{
   DataSet ds = new DataSet(); 
   ds.ReadXml(createdText)

   string filenamewithpath = System.Web.HttpContext.Current.Server.MapPath(@"~/files/" + id+".xml");
   ds.WriteXml(filenamewithpath);      
}

Upvotes: 1

Related Questions