XmlNodeReader.BaseURI Vlastnost

Definice

Získá základní identifikátor URI aktuálního uzlu.

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

Hodnota vlastnosti

String

Základní identifikátor URI aktuálního uzlu.

Příklady

Následující příklad analyzuje soubor a zobrazí základní identifikátor URI každého uzlu.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlNodeReader^ reader = nullptr;
   try
   {
      
      //Create and load an XmlDocument.
      XmlDocument^ doc = gcnew XmlDocument;
      doc->Load( "http://localhost/uri.xml" );
      reader = gcnew XmlNodeReader( doc );
      
      //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()
  {
    XmlNodeReader reader = null;

    try
    {
        //Create and load an XmlDocument.
        XmlDocument doc = new XmlDocument();
        doc.Load("http://localhost/uri.xml");

        reader = new XmlNodeReader(doc);

        //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 XmlNodeReader = Nothing
        
        Try
            'Create and load an XmlDocument.
            Dim doc As New XmlDocument()
            doc.Load("http://localhost/uri.xml")
            
            reader = New XmlNodeReader(doc)
            
            '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

Příklad používá soubor , uri.xmljako vstup.


<!-- XML fragment -->
<!DOCTYPE book [<!ENTITY s SYSTEM "tmp/style.xml">]>
<book genre="novel">
  <title>Pride And Prejudice</title>
  <misc>&s;</misc>
</book>

Soubor style.xml obsahuje text <style>hardcover</style>XML .

Poznámky

Poznámka

V .NET Framework 2.0 doporučujeme vytvořit XmlReader instance pomocí XmlReaderSettings třídy a Create metody. Díky tomu můžete plně využít všechny nové funkce představené v .NET Framework. Další informace najdete v části Poznámky na XmlReader referenční stránce.

Síťový dokument XML se skládá z bloků dat agregovaných pomocí různých mechanismů zahrnutí standardu W3C, a proto obsahuje uzly pocházející z různých míst. Entity DTD jsou příkladem tohoto příkladu, ale není omezena na identifikátory DTD. Základní identifikátor URI vám řekne, odkud tyto uzly pocházejí. Pokud pro vrácené uzly neexistuje žádný základní identifikátor URI (například byly analyzovány z řetězce v paměti), vrátí se string.Empty.

Platí pro