Namespace:
System.Xml
Assembly:
System.Xml (in System.Xml.dll)
Visual Basic (Declaration)
Public Shared Function Create ( _
reader As XmlReader, _
settings As XmlReaderSettings _
) As XmlReader
Dim reader As XmlReader
Dim settings As XmlReaderSettings
Dim returnValue As XmlReader
returnValue = XmlReader.Create(reader, _
settings)
public static XmlReader Create(
XmlReader reader,
XmlReaderSettings settings
)
public:
static XmlReader^ Create(
XmlReader^ reader,
XmlReaderSettings^ settings
)
public static function Create(
reader : XmlReader,
settings : XmlReaderSettings
) : XmlReader
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. 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.
Security Note: |
|---|
You can use one of the following methods to control which resources the XmlReader can access: Restrict the resources that the XmlReader can access by setting the XmlResolver property to an XmlSecureResolver object. -or- Do not allow the XmlReader to open any external resources by setting the XmlResolver property to nullNothingnullptra null reference (Nothing in Visual Basic). |
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.
' Create the XmlNodeReader object.
Dim doc As New XmlDocument()
doc.Load("books.xml")
Dim nodeReader As New XmlNodeReader(doc)
' Set the validation settings.
Dim settings As New XmlReaderSettings()
settings.ValidationType = ValidationType.Schema
settings.Schemas.Add("urn:bookstore-schema", "books.xsd")
AddHandler settings.ValidationEventHandler, AddressOf ValidationCallBack
' Create a validating reader that wraps the XmlNodeReader object.
Dim reader As XmlReader = XmlReader.Create(nodeReader, settings)
' Parse the XML file.
While reader.Read()
End While
// Create the XmlNodeReader object.
XmlDocument doc = new XmlDocument();
doc.Load("books.xml");
XmlNodeReader nodeReader = new XmlNodeReader(doc);
// Set the validation settings.
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.Schemas.Add("urn:bookstore-schema", "books.xsd");
settings.ValidationEventHandler += new ValidationEventHandler (ValidationCallBack);
// Create a validating reader that wraps the XmlNodeReader object.
XmlReader reader = XmlReader.Create(nodeReader, settings);
// Parse the XML file.
while (reader.Read());
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0, 2.0
.NET Compact Framework
Supported in: 3.5, 2.0
XNA Framework
Supported in: 3.0, 2.0, 1.0
Reference
Other Resources