本文整理匯總了VB.NET中System.Xml.XmlResolver類的典型用法代碼示例。如果您正苦於以下問題:VB.NET XmlResolver類的具體用法?VB.NET XmlResolver怎麽用?VB.NET XmlResolver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了XmlResolver類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Main
' 導入命名空間
Imports System.Xml
Imports System.IO
Module Module1
Sub Main()
' Create an XmlUrlResolver with default credentials.
Dim resolver As New XmlUrlResolver()
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials
' Point the resolver at the desired resource and resolve as a stream.
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)
' Create the reader with the resolved stream and display the data.
Dim reader As XmlReader = XmlReader.Create(s)
While reader.Read()
Console.WriteLine(reader.ReadOuterXml())
End While
End Sub
End Module
示例2: XmlUrlResolver
' Create a resolver with default credentials.
Dim resolver as XmlUrlResolver = new XmlUrlResolver()
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials
' Set the reader settings object to use the resolver.
settings.XmlResolver = resolver
' Create the XmlReader object.
Dim reader as XmlReader = XmlReader.Create("http://ServerName/data/books.xml", settings)
示例3: NetworkCredential
' Create the credentials.
Dim myCred As NetworkCredential = New NetworkCredential(UserName,SecurelyStoredPassword,Domain)
Dim myCache As CredentialCache = New CredentialCache()
myCache.Add(new Uri("http://www.contoso.com/"), "Basic", myCred)
myCache.Add(new Uri("http://app.contoso.com/"), "Basic", myCred)
' Set the credentials on the XmlUrlResolver object.
Dim resolver As XmlUrlResolver = New XmlUrlResolver()
resolver.Credentials = myCache
' Compile the style sheet.
Dim xslt As XslCompiledTransform = New XslCompiledTransform()
xslt.Load("http://serverName/data/xsl/order.xsl", XsltSettings.Default, resolver)