XmlTextReader.BaseURI Özellik

Tanım

Geçerli düğümün temel URI'sini alır.

public:
 virtual property System::String ^ BaseURI { System::String ^ get(); };
public override string? BaseURI { get; }
public override string BaseURI { get; }
member this.BaseURI : string
Public Overrides ReadOnly Property BaseURI As String

Özellik Değeri

String

Geçerli düğümün temel URI'si.

Örnekler

Aşağıdaki örnek, düğümlerin her biri için temel URI'yi görüntüler.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlTextReader^ reader = nullptr;
   try
   {
      
      //Load the reader with the XML file.
      reader = gcnew XmlTextReader( "http://localhost/baseuri.xml" );
      
      //Parse the file and display the base URI for each node.
      while ( reader->Read() )
      {
         Console::WriteLine( "({0}) {1}", reader->NodeType, reader->BaseURI );
      }
   }
   finally
   {
      if ( reader != nullptr )
            reader->Close();
   }

}
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {
    XmlTextReader reader = null;

    try
    {
        //Load the reader with the XML file.
        reader = new XmlTextReader("http://localhost/baseuri.xml");

        //Parse the file and display the base URI for each node.
        while (reader.Read())
        {
            Console.WriteLine("({0}) {1}", reader.NodeType, reader.BaseURI);
         }
     }

     finally
     {
       if (reader!=null)
         reader.Close();
     }
  }
} // End class
Option Explicit
Option Strict

Imports System.IO
Imports System.Xml

Public Class Sample
   
   Public Shared Sub Main()
      Dim reader As XmlTextReader = Nothing
      
      Try
         'Load the reader with the XML file.
         reader = New XmlTextReader("http://localhost/baseuri.xml")
         
         'Parse the file and display the base URI for each node.
         While reader.Read()
            Console.WriteLine("({0}) {1}", reader.NodeType, reader.BaseURI)
         End While
      
      Finally
         If Not (reader Is Nothing) Then
            reader.Close()
         End If
      End Try
   End Sub
End Class

Örnekte giriş baseuri.xmlolarak dosyası kullanılır.


<!-- XML fragment -->
<book genre="novel">
  <title>Pride And Prejudice</title>
</book>

Açıklamalar

Not

.NET Framework 2.0'dan başlayarak, yeni işlevlerden yararlanmak için yöntemini kullanarak XmlReader.Create örnekler oluşturmanızı XmlReader öneririz.

Ağa bağlı XML belgesi, çeşitli W3C standart ekleme mekanizmaları kullanılarak toplanan veri öbeklerinden oluşur ve bu nedenle farklı yerlerden gelen düğümleri içerir. DTD varlıkları bunun bir örneğidir, ancak bu DTD'lerle sınırlı değildir. Temel URI, bu düğümlerin nereden geldiğini bildirir. Döndürülen düğümler için temel URI yoksa (örneğin, bunlar bellek içi dizeden ayrıştırıldı), String.Empty döndürülür.

Şunlara uygulanır

Ayrıca bkz.