This documentation is archived and is not being maintained.

XmlDocument.Load Method (Stream)

Loads the XML document from the specified stream.

Namespace: System.Xml
Assembly: System.Xml (in system.xml.dll)

public virtual void Load (
	Stream inStream
public void Load (
	Stream inStream
public function Load (
	inStream : Stream



The stream containing the XML document to load.

Exception typeCondition


There is a load or parse error in the XML. In this case, the document remains empty.


The Load method always preserves significant white space. The PreserveWhitespace property determines whether or not insignificant white space, that is white space in element content, is preserved. The default is false; white space in element content is not preserved.

This method does not do DTD or schema validation. If you want validation to occur, you need to pass an XmlValidatingReader, specify the appropriate XmlValidatingReader.ValidationType, and provide a XmlValidatingReader.ValidationEventHandler. You are then notified of all validation errors found during Load, and unless your ValidationEventHandler throws an exception to stop the process, the document will still be loaded. See XmlDocument for an example of load-time validation

This method is a Microsoft extension to the Document Object Model (DOM).

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0