Once you have retrieved data from a web service you will need to do something with it. This HOWTO describes the various built-in methods .NET provides to use XML returned by a web service.
The .NET Framework provides excellent support for XML. Combined with the databinding support of WinForms and ASP.NET applications
you have an easy and powerful set of tools. ASP.NET 2.0 takes databinding another step further by providing the
DataSource control which lets you declaratively provide data access to data-bound UI controls.
The simplest way to view the returned data is to get the response stream and put it into a string. This is especially handy for debugging. The following code gets a web page and returns the contents as a string.
XmlReader provides fast forward-only access to XML data. It also allows you to read data as simple-typed
values rather than strings.
XmlReader can load an XML document without having to use
you won't have the same amount of control over the request. If you use
HttpRequest, you can just pass the stream
returned by the
GetResponseStream() method to
XmlReader. Fast write-only functions are provided by
With .NET 2.0 you should create
XmlReader instances using the
method. For the sake of compatibility and clarity the next sample uses the .NET 1.1 creation method.
XmlDocument gives more flexibility and is a good choice if you need to navigate or modify the data via the DOM.
It also works as a source for the
XslTransform class allowing you to perform XSL transformations.
XPathDocument provides fast, read-only access to the contents of an XML document using XPath. Its usage
is similar to using XPath with
DataSet from the
System.Data namespace lets you bind the returned data
to controls and also access hierarchical data easily. A dataset can infer the structure automatically from XML,
create corresponding tables and relationships between them and populate the tables just by calling
Related information on the web is listed below.