XmlAttribute.BaseURI Egenskap

Definition

Hämtar nodens grundläggande URI (Uniform Resource Identifier).

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

Egenskapsvärde

Platsen som noden lästes in från eller String.Empty om noden inte har någon bas-URI. Attributnoder har samma bas-URI som ägarelementet. Om en attributnod inte har något ägarelement BaseURI returnerar String.Empty.

Exempel

I följande exempel visas information om attributnoden, inklusive dess bas-URI.

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

Exemplet använder filen , baseuri.xmlsom indata.


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

Kommentarer

Ett nätverksanslutet XML-dokument består av datasegment aggregerade med hjälp av olika W3C-standardinkluderingsmekanismer (World Wide Web Consortium) och innehåller därför noder som kommer från olika platser. BaseURI Anger var dessa noder kom ifrån.

Mer information om BaseURI och hur den fungerar med andra nodtyper finns i XmlNode.BaseURI.

Den här egenskapen är ett Microsoft tillägg till dokumentobjektmodellen (DOM).

Gäller för

Se även