XmlResolver resolves external XML resources named by a Uniform Resource Identifier (URI). : XmlResolver « XML « VB.Net






XmlResolver resolves external XML resources named by a Uniform Resource Identifier (URI).

  
Imports System
Imports System.Xml
Imports System.IO

Module Module1

    Sub Main()
        Dim resolver As New XmlUrlResolver()
        resolver.Credentials = System.Net.CredentialCache.DefaultCredentials

        Dim baseUri As New Uri("http://serverName/")
        Dim fulluri As Uri = resolver.ResolveUri(baseUri, "fileName.xml")
        Dim s As Stream = CType(resolver.GetEntity(fulluri, Nothing, GetType(Stream)), Stream)

        Dim reader As XmlReader = XmlReader.Create(s)
        While reader.Read()
            Console.WriteLine(reader.ReadOuterXml())
        End While
    End Sub
End Module

   
    
  








Related examples in the same category

1.Sets the XmlResolver to use for resolving external resources.
2.Sets the XmlResolver used for resolving DTD references.