How Do I...? Common Tasks QuickStart Tutorial
How Do I...Read XML data from a stream?
This sample illustrates how to read XML from a stream using the XmlReader class. The stream could have come from a variety of sources, such as a byte stream from a server, a file, or a TextReader.
Note: This sample follows on from the How do I...Read XML from a file? topic.
VB ReadXmlStream.exe
[This sample can be found at H:\Home\WU_000036_efe47225c86ca62f325a01d8519bc002\Webs\aspnet.sk\quickstarts\QuickStartv20\howto\samples\Xml\ReadXmlStream\
To build this sample, open the SDK command prompt and navigate to the above path. Build the sample using the build tool msbuild
passing the solution file as the first parameter: msbuild mySample.sln. The compiled executable will be found in the sub directory \bin
directory.]
The static Create method on the XmlReader has different overloads to specify the location of the XML data. This sample creates the XmlReader and loads the data from a stream. A stream is an abstract representation of an input or output device that is the source of or destination for data (in this case, XML data). You can write to a stream and read from a stream, which is best visualized as a flow of bytes. A stream provides independence from the device and requires no program changes if, for example, the source of a stream changes.
This sample creates a StringReader class that builds up an XML string. Because this is purely a byte stream held in memory, you can get the XmlReader to parse this stream as XML. The memory stream has no particular specified encoding.
'Create XmlReader and load reader from stream
reader = XmlReader.Create(stream)
VB
Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2005 Microsoft Corporation. All rights reserved.
|