當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET XmlResolver類代碼示例

本文整理匯總了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
開發者ID:VB.NET開發者,項目名稱:System.Xml,代碼行數:23,代碼來源:XmlResolver

示例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)
開發者ID:VB.NET開發者,項目名稱:System.Xml,代碼行數:9,代碼來源:XmlResolver

示例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)
開發者ID:VB.NET開發者,項目名稱:System.Xml,代碼行數:13,代碼來源:XmlResolver


注:本文中的System.Xml.XmlResolver類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。