XmlTextReader.BaseURI 속성

정의

현재 노드의 기본 URI를 가져옵니다.

public:
 virtual property System::String ^ BaseURI { System::String ^ get(); };
public override string? BaseURI { get; }
public override string BaseURI { get; }
member this.BaseURI : string
Public Overrides ReadOnly Property BaseURI As String

속성 값

String

현재 노드의 기본 URI입니다.

예제

다음 예제에서는 각 노드에 대한 기본 URI를 표시합니다.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlTextReader^ reader = nullptr;
   try
   {
      
      //Load the reader with the XML file.
      reader = gcnew XmlTextReader( "http://localhost/baseuri.xml" );
      
      //Parse the file and display the base URI for each node.
      while ( reader->Read() )
      {
         Console::WriteLine( "({0}) {1}", reader->NodeType, reader->BaseURI );
      }
   }
   finally
   {
      if ( reader != nullptr )
            reader->Close();
   }

}
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {
    XmlTextReader reader = null;

    try
    {
        //Load the reader with the XML file.
        reader = new XmlTextReader("http://localhost/baseuri.xml");

        //Parse the file and display the base URI for each node.
        while (reader.Read())
        {
            Console.WriteLine("({0}) {1}", reader.NodeType, reader.BaseURI);
         }
     }

     finally
     {
       if (reader!=null)
         reader.Close();
     }
  }
} // End class
Option Explicit
Option Strict

Imports System.IO
Imports System.Xml

Public Class Sample
   
   Public Shared Sub Main()
      Dim reader As XmlTextReader = Nothing
      
      Try
         'Load the reader with the XML file.
         reader = New XmlTextReader("http://localhost/baseuri.xml")
         
         'Parse the file and display the base URI for each node.
         While reader.Read()
            Console.WriteLine("({0}) {1}", reader.NodeType, reader.BaseURI)
         End While
      
      Finally
         If Not (reader Is Nothing) Then
            reader.Close()
         End If
      End Try
   End Sub
End Class

이 예제에서는 파일을 baseuri.xml입력으로 사용합니다.


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

설명

참고

.NET Framework 2.0부터 새 기능을 활용하기 위해 메서드를 XmlReader.Create 사용하여 인스턴스를 만드는 XmlReader 것이 좋습니다.

네트워크로 구성된 XML 문서는 다양한 W3C 표준 포함 메커니즘을 사용하여 집계된 데이터 청크로 구성되므로 서로 다른 위치에서 온 노드가 포함됩니다. DTD 엔터티는 이러한 예이지만 DTD로 제한되지는 않습니다. 기본 URI는 이러한 노드의 원본 위치를 알려줍니다. 반환되는 노드에 대한 기본 URI가 없는 경우(예: 메모리 내 문자열에서 구문 분석된 노드) String.Empty 반환됩니다.

적용 대상

추가 정보