XmlValidatingReader.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; }
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()
{
   XmlValidatingReader^ reader = nullptr;
   XmlTextReader^ txtreader = nullptr;
   try
   {
      
      //Create the validating reader.
      txtreader = gcnew XmlTextReader( "http://localhost/uri.xml" );
      reader = gcnew XmlValidatingReader( txtreader );
      reader->ValidationType = ValidationType::None;
      
      //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()
  {
    XmlValidatingReader reader = null;
    XmlTextReader txtreader = null;

    try
    {
        //Create the validating reader.
        txtreader = new XmlTextReader("http://localhost/uri.xml");
        reader = new XmlValidatingReader(txtreader);
        reader.ValidationType = ValidationType.None;

        //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 Strict
Option Explicit

Imports System.IO
Imports System.Xml

Public Class Sample
   
   Public Shared Sub Main()
      Dim reader As XmlValidatingReader = Nothing
      Dim txtreader As XmlTextReader = Nothing
      
      Try
         'Create the validating reader.
         txtreader = New XmlTextReader("http://localhost/uri.xml")
         reader = New XmlValidatingReader(txtreader)
         reader.ValidationType = ValidationType.None
         
         '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

Třída XmlValidatingReader je zastaralá v rozhraní .NET Framework 2.0. Ověřování instance můžete vytvořit XmlReader pomocí XmlReaderSettings třídy a Create metody. Další informace najdete v části Poznámky referenční XmlReader stránky.

Síťový dokument XML se skládá z bloků dat agregovaných pomocí různých standardních mechanismů zahrnutí konsorcia W3C (World Wide Web Consortium), a proto obsahuje uzly, které pocházejí z různých míst. Příkladem jsou entity definice typu dokumentu (DTD), které ale nejsou omezené na DTD. Základní identifikátor URI vám říká, 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

Viz také