Bagikan melalui


XmlAttribute.BaseURI Properti

Definisi

Mendapatkan Pengidentifikasi Sumber Daya Seragam (URI) dasar dari simpul.

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

Nilai Properti

Lokasi tempat simpul dimuat atau String.Empty jika simpul tidak memiliki URI dasar. Node atribut memiliki URI dasar yang sama dengan elemen pemiliknya. Jika simpul atribut tidak memiliki elemen pemilik, BaseURI mengembalikan String.Empty.

Contoh

Contoh berikut menampilkan informasi tentang simpul atribut, termasuk URI dasarnya.

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

Sampel menggunakan file, baseuri.xml, sebagai input.


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

Keterangan

Dokumen XML berjaringan terdiri dari potongan data yang dikumpulkan menggunakan berbagai mekanisme penyertaan standar World Wide Web Consortium (W3C) dan oleh karena itu berisi simpul yang berasal dari tempat yang berbeda. Memberi BaseURI tahu Anda dari mana simpul ini berasal.

Untuk informasi tambahan tentang BaseURI dan bagaimana perilakunya dengan jenis node lain, lihat XmlNode.BaseURI.

Properti ini adalah ekstensi Microsoft ke Model Objek Dokumen (DOM).

Berlaku untuk

Lihat juga