XmlEntityReference.BaseURI Właściwość

Definicja

Pobiera podstawowy identyfikator URI bieżącego węzła.

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

Wartość właściwości

Lokalizacja, z której został załadowany węzeł.

Przykłady

Poniższy przykład przedstawia informacje dotyczące węzła odwołania do jednostki, w tym jego podstawowy identyfikator URI.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   
   //Create the XmlDocument.
   XmlDocument^ doc = gcnew XmlDocument;
   doc->Load( "http://localhost/uri.xml" );
   
   //Display information on the entity reference node.
   XmlEntityReference^ entref = dynamic_cast<XmlEntityReference^>(doc->DocumentElement->LastChild->FirstChild);
   Console::WriteLine( "Name of the entity reference:  {0}", entref->Name );
   Console::WriteLine( "Base URI of the entity reference:  {0}", entref->BaseURI );
   Console::WriteLine( "The entity replacement text:  {0}", entref->InnerText );
}
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {
    //Create the XmlDocument.
    XmlDocument doc = new XmlDocument();
    doc.Load("http://localhost/uri.xml");

    //Display information on the entity reference node.
    XmlEntityReference entref = (XmlEntityReference) doc.DocumentElement.LastChild.FirstChild;
    Console.WriteLine("Name of the entity reference:  {0}", entref.Name);
    Console.WriteLine("Base URI of the entity reference:  {0}", entref.BaseURI);
    Console.WriteLine("The entity replacement text:  {0}", entref.InnerText);
  }
}
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()
  
    'Create the XmlDocument.
    Dim doc as XmlDocument = new XmlDocument()
    doc.Load("http://localhost/uri.xml")
                     
    'Display information on the entity reference node.
    Dim entref as XmlEntityReference =  CType(doc.DocumentElement.LastChild.FirstChild, XmlEntityReference) 
    Console.WriteLine("Name of the entity reference:  {0}", entref.Name)
    Console.WriteLine("Base URI of the entity reference:  {0}", entref.BaseURI)
    Console.WriteLine("The entity replacement text:  {0}", entref.InnerText)
  end sub
end class

W przykładzie użyto pliku , uri.xmljako danych wejściowych.


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

Plik style.xml zawiera ciąg <style>hardcover</style>XML .

Uwagi

Dokument XML w sieci składa się z fragmentów danych zagregowanych przy użyciu różnych standardowych mechanizmów dołączania konsorcjum World Wide Web Consortium (W3C) i w związku z tym zawiera węzły pochodzące z różnych miejsc. Polecenie BaseURI informuje o tym, skąd pochodzą te węzły. Jeśli nie ma podstawowego identyfikatora URI dla zwracanych węzłów (być może zostały przeanalizowane z ciągu w pamięci), Empty jest zwracany.

BaseURI Przechodzi do drzewa węzłów szukającego granic odwołania do jednostki, więc jeśli jednostki są rozwinięte, te informacje nie są zachowywane i ta właściwość zwraca lokalizację obiektu XmlDocument we wszystkich przypadkach.

Aby uzyskać dodatkowe informacje na BaseURI temat tego, jak zachowuje się on z innymi typami węzłów, zobacz XmlNode.BaseURI.

Ta właściwość jest rozszerzeniem firmy Microsoft do modelu obiektów dokumentów (DOM).

Dotyczy