Create Method (XmlReader, XmlReaderSettings)

XmlReader.Create Method (XmlReader, XmlReaderSettings)

 

Creates a new XmlReader instance by using the specified XML reader and settings.

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

static member Create : 
        reader:XmlReader *
        settings:XmlReaderSettings -> XmlReader

Parameters

reader
Type: System.Xml.XmlReader

The object that you want to use as the underlying XML reader.

settings
Type: System.Xml.XmlReaderSettings

The settings for the new XmlReader instance.

The conformance level of the XmlReaderSettings object must either match the conformance level of the underlying reader, or it must be set to Auto.

Return Value

Type: System.Xml.XmlReader

An object that is wrapped around the specified XmlReader object.

Exception Condition
ArgumentNullException

The reader value is null.

InvalidOperationException

If the XmlReaderSettings object specifies a conformance level that is not consistent with conformance level of the underlying reader.

-or-

The underlying XmlReader is in an Error or Closed state.

This method allows you add additional features to an underlying XmlReader object. The underlying XmlReader object can be another XmlReader object created by the Create method, or an XmlReader object created using one of the concrete XmlReader implementations.

A default XmlUrlResolver with no credentials is used to access any external resources such as a schema.

System_CAPS_importantImportant

Starting with the .NET Framework 4.5.2, no default XmlUrlResolver is provided. If your solution targets the .NET Framework 4.5.2 or later versions, specify an XmlResolver using the XmlReaderSettings.XmlResolver property.

If the external resource is located on a network resource that requires authentication, specify an XmlResolver with the necessary credentials using the XmlReaderSettings.XmlResolver property.

System_CAPS_security Security Note

You can use one of the following methods to control which resources the XmlReader can access:

-or-

  • Do not allow the XmlReader to open any external resources by setting the XmlResolver property to null.

The created XmlReader object expands entity references and performs XML normalization of new line characters.

The following example creates a validating XmlReader object that is wrapped around an XmlNodeReader object.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2016 Microsoft