XmlNodeReader.BaseURI 속성

정의

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

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입니다.

예제

다음 예제에서는 파일을 구문 분석하고 각 노드의 기본 URI를 표시합니다.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlNodeReader^ reader = nullptr;
   try
   {
      
      //Create and load an XmlDocument.
      XmlDocument^ doc = gcnew XmlDocument;
      doc->Load( "http://localhost/uri.xml" );
      reader = gcnew XmlNodeReader( doc );
      
      //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()
  {
    XmlNodeReader reader = null;

    try
    {
        //Create and load an XmlDocument.
        XmlDocument doc = new XmlDocument();
        doc.Load("http://localhost/uri.xml");

        reader = new XmlNodeReader(doc);

        //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 XmlNodeReader = Nothing
        
        Try
            'Create and load an XmlDocument.
            Dim doc As New XmlDocument()
            doc.Load("http://localhost/uri.xml")
            
            reader = New XmlNodeReader(doc)
            
            '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

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


<!-- XML fragment -->
<!DOCTYPE book [<!ENTITY s SYSTEM "tmp/style.xml">]>
<book genre="novel">
  <title>Pride And Prejudice</title>
  <misc>&s;</misc>
</book>

파일에 XML style.xml 텍스트 <style>hardcover</style>가 포함되어 있습니다.

설명

참고

.NET Framework 2.0에서는 클래스와 Create 메서드를 사용하여 인스턴스를 XmlReaderSettings 만드는 XmlReader 것이 좋습니다. 이렇게 하면 .NET Framework 도입된 모든 새로운 기능을 최대한 활용할 수 있습니다. 자세한 내용은 참조 페이지의 설명 섹션을 XmlReader 참조하세요.

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

적용 대상