Creates a new XmlReader instance.
This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.
Although Microsoft .NET Framework includes concrete implementations of the XmlReader class, such as the XmlTextReader, XmlNodeReader, and the XmlValidatingReader classes, in the 2.0 release the recommended practice is to create XmlReader instances using the method. For more information, see Creating XML Readers.
By default the XmlReader uses an XmlUrlResolver object with no user credentials to open resources. This means that, by default, the XmlReader can access any locations that do not require credentials. You can use one of the following methods to control which resources the XmlReader can access:
The following example uses an XmlUrlResolver with default credentials to access a file.
// Set the reader settings. XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreComments = true; settings.IgnoreProcessingInstructions = true; settings.IgnoreWhitespace = true;
// Create a resolver with default credentials. XmlUrlResolver resolver = new XmlUrlResolver(); resolver.Credentials = System.Net.CredentialCache.DefaultCredentials; // Set the reader settings object to use the resolver. settings.XmlResolver = resolver; // Create the XmlReader object. XmlReader reader = XmlReader.Create("http://ServerName/data/books.xml", settings);
// Create a resolver with default credentials. XmlUrlResolver* resolver = new XmlUrlResolver(); resolver->Credentials = System::Net::CredentialCache::DefaultCredentials; // Create the XmlReader object. XmlReader* reader = XmlReader::Create(S"http://ServerName/data/books.xml", 0, resolver, settings);