c# - Create XML file from REST response -


i have following method making rest request returns data in xml format -

public void test()     {         string requesturi = string.empty;          try         {             requesturi = string.format("uri/{0}?locales={1}", "test", "en-gb");              httpclient client = new httpclient();             client.baseaddress = new uri(requesturi);              httpresponsemessage response = client.getasync(requesturi).result;             if (response.issuccessstatuscode)             {                 string content = response.content.readasstringasync().result;                 // want create xml file here                 this.writetofile(content);             }         }         catch (exception)         {             throw;         }     } 

how can create xml file response got api?

since content xml change this.writetofile(content) to

file.writealltext("foo.xml", content); 

also try {} catch (exception e) {throw e} bad. rethrowing loose stack information. nothing , thrown exceptions bubble caller.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -