Export (0) Print
Expand All

XmlReader.Create Method (String, XmlReaderSettings, XmlParserContext)

Creates a new XmlReader instance using the specified URI, XmlReaderSettings, and XmlParserContext objects.

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

public static XmlReader Create(
	string inputUri,
	XmlReaderSettings settings,
	XmlParserContext inputContext
)

Parameters

inputUri
Type: System.String
The URI for the file containing the XML data. The XmlResolver object on the XmlReaderSettings object is used to convert the path to a canonical data representation. If XmlResolver is null, a new XmlXapResolver object is used. For more information, see the Remarks section below.
settings
Type: System.Xml.XmlReaderSettings
The XmlReaderSettings object used to configure the new XmlReader instance. This value can be null.
inputContext
Type: System.Xml.XmlParserContext
The XmlParserContext object that provides the context information required to parse the XML fragment. The context information can include the XmlNameTable to use, encoding, namespace scope, the current xml:lang and xml:space scope, base URI, and document type definition.
This value can be null.

Return Value

Type: System.Xml.XmlReader
An XmlReader object to read XML data.

ExceptionCondition
NullReferenceException

The inputUri value is null.

SecurityException

The XmlReader does not have sufficient permissions to access the location of the XML data.

ArgumentException

The XmlReaderSettings.NameTable and XmlParserContext.NameTable properties both contain values. (Only one of these NameTable properties can be set and used).

FileNotFoundException

The file specified by the URI cannot be found.

UriFormatException

The URI format is not correct.

The inputUri parameter contains the URI to the XML file. This file must be located in the application's XAP resource, unless the XmlResolver has been changed to something other than XmlXapResolver. If you want to download the file from some other location, you must do the following:

  1. Download the data. To do this, initiate an asynchronous request by using HttpWebRequest.

  2. Create an XmlReader by calling one of the Create overloads that take Stream as a parameter and pass the returned Stream that contains the data..

For a code example, see How to: Load an XML File from an Arbitrary URI Location with LINQ to XML.

For information on working with resolvers, see Working with XmlXapResolver, Working with XmlPreloadedResolver.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft