XmlAttribute.BaseURI Vlastnost

Definice

Získá základní identifikátor URI (Uniform Resource Identifier) 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

Umístění, ze kterého byl uzel načten nebo String.Empty, pokud uzel nemá žádný základní identifikátor URI. Uzly atributů mají stejný základní identifikátor URI jako element vlastníka. Pokud uzel atributu nemá element owner, BaseURI vrátí hodnotu String.Empty.

Příklady

Následující příklad zobrazí informace o uzlu atributu, včetně jeho základního identifikátoru 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/baseuri.xml" );
   
   //Display information on the attribute node. The value
   //returned for BaseURI is 'http://localhost/baseuri.xml'.
   XmlAttribute^ attr = doc->DocumentElement->Attributes[ 0 ];
   Console::WriteLine( "Name of the attribute:  {0}", attr->Name );
   Console::WriteLine( "Base URI of the attribute:  {0}", attr->BaseURI );
   Console::WriteLine( "The value of the attribute:  {0}", attr->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/baseuri.xml");

    //Display information on the attribute node. The value
    //returned for BaseURI is 'http://localhost/baseuri.xml'.
    XmlAttribute attr = doc.DocumentElement.Attributes[0];
    Console.WriteLine("Name of the attribute:  {0}", attr.Name);
    Console.WriteLine("Base URI of the attribute:  {0}", attr.BaseURI);
    Console.WriteLine("The value of the attribute:  {0}", attr.InnerText);
  }
}
Option Explicit
Option Strict

Imports System.IO
Imports System.Xml

Public Class Sample
    
    Public Shared Sub Main()
        'Create the XmlDocument.
        Dim doc As New XmlDocument()
        doc.Load("http://localhost/baseuri.xml")
        
        'Display information on the attribute node. The value
        'returned for BaseURI is 'http://localhost/baseuri.xml'.
        Dim attr As XmlAttribute = doc.DocumentElement.Attributes(0)
        Console.WriteLine("Name of the attribute:  {0}", attr.Name)
        Console.WriteLine("Base URI of the attribute:  {0}", attr.BaseURI)
        Console.WriteLine("The value of the attribute:  {0}", attr.InnerText)
    End Sub
End Class

Ukázka používá soubor , baseuri.xmljako vstup.


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

Poznámky

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. Řekne BaseURI vám, odkud tyto uzly pocházejí.

Další informace o BaseURI chování s jinými typy uzlů najdete v tématu XmlNode.BaseURI.

Tato vlastnost je rozšířením Microsoftu pro model DOM (Document Object Model).

Platí pro

Viz také