Skip to content

My Super Generic Webservice DataTable to serialisable XML string method call Part 2

February 7, 2016

Further upon the super generic webservice method I wrote, on the web service side end, you can obtain the Stream fairly easily and convert to a datatable, here is how: –

public string getXMLStream(Stream data)
    // Convert Stream Data to StreamReader
    StreamReader reader = new StreamReader(data);

    // Read StreamReader data as String
    string xmlString = reader.ReadToEnd();
    // Convert to DataTable from XML String
    DataTable dataTable = ConvertXMLToDataTable(xmlString);

    string returnValue = xmlString;
The rather useful converter is also shown here.

public DataTable ConvertXMLTODataTable(string xmlData)
    StringReader reader = new StringReader(xmlData);
    DataSet dataSet = new DataSet();
    schemaName = dataSet.DataSetName;
    return dataSet.Tables[0];

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: