다음을 통해 공유


XmlAttribute.BaseURI 속성

정의

노드의 기본 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

속성 값

노드가 로드된 위치이거나 노드에 기본 URI가 없는 경우 String.Empty입니다. 특성 노드에는 소유자 요소와 동일한 기본 URI가 있습니다. 특성 노드에 소유자 요소가 BaseURI 없으면 String.Empty를 반환합니다.

예제

다음 예제에서는 기본 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

샘플은 파일을 baseuri.xml입력으로 사용합니다.


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

설명

네트워크로 구성된 XML 문서는 다양한 W3C(World Wide Web 컨소시엄) 표준 포함 메커니즘을 사용하여 집계된 데이터 청크로 구성되므로 다른 위치에서 온 노드가 포함됩니다. 이 BaseURI 노드는 어디에서 왔는지 알려줍니다.

다른 노드 형식과 함께 동작하는 방법에 대한 BaseURI 자세한 내용은 다음을 참조하세요 XmlNode.BaseURI.

이 속성은 DOM(문서 개체 모델)에 대한 Microsoft 확장입니다.

적용 대상

추가 정보