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

속성 값

String

노드가 로드된 위치이거나 노드에 기본 URI가 없으면 String.Empty입니다. Attribute 노드의 기본 URI는 해당 노드의 소유자 요소의 기본 URI와 같습니다. Attribute 노드에 소유자 요소가 없으면, BaseURI가 String.Empty를 반환합니다.

예제

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

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


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

설명

네트워크로 구성된 XML 문서는 다양한 W3C(World Wide Web Consortium) 표준 포함 메커니즘을 사용하여 집계된 데이터 청크로 구성되므로 서로 다른 위치에서 온 노드를 포함합니다. 이 BaseURI 노드는 이러한 노드의 위치를 알려줍니다.

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

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

적용 대상

추가 정보