XmlNodeReader.MoveToAttribute 메서드

정의

지정된 특성으로 이동합니다.

오버로드

MoveToAttribute(Int32)

지정된 인덱스가 있는 특성으로 이동합니다.

MoveToAttribute(String)

지정된 이름이 있는 특성으로 이동합니다.

MoveToAttribute(String, String)

지정된 로컬 이름과 네임스페이스 URI가 있는 특성으로 이동합니다.

MoveToAttribute(Int32)

지정된 인덱스가 있는 특성으로 이동합니다.

public:
 override void MoveToAttribute(int attributeIndex);
public override void MoveToAttribute (int attributeIndex);
override this.MoveToAttribute : int -> unit
Public Overrides Sub MoveToAttribute (attributeIndex As Integer)

매개 변수

attributeIndex
Int32

특성의 인덱스입니다.

예외

i 매개 변수가 0보다 작거나 AttributeCount보다 크거나 같은 경우

예제

다음 예제에서는 루트 노드의 모든 특성을 읽습니다.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlNodeReader^ reader = nullptr;
   try
   {
      
      //Create and load the XML document.
      XmlDocument^ doc = gcnew XmlDocument;
      doc->LoadXml( "<book genre='novel' ISBN='1-861003-78' publicationdate='1987'> "
      "</book>" );
      
      //Load the XmlNodeReader 
      reader = gcnew XmlNodeReader( doc );
      
      //Read the attributes on the root element.
      reader->MoveToContent();
      if ( reader->HasAttributes )
      {
         for ( int i = 0; i < reader->AttributeCount; i++ )
         {
            reader->MoveToAttribute( i );
            Console::WriteLine( "{0} = {1}", reader->Name, reader->Value );

         }
         reader->MoveToElement();
      }
   }
   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 the XML document.
       XmlDocument doc = new XmlDocument();
       doc.LoadXml("<book genre='novel' ISBN='1-861003-78' publicationdate='1987'> " +
                   "</book>");

       //Load the XmlNodeReader
       reader = new XmlNodeReader(doc);

       //Read the attributes on the root element.
       reader.MoveToContent();
       if (reader.HasAttributes){
         for (int i=0; i<reader.AttributeCount; i++){
            reader.MoveToAttribute(i);
            Console.WriteLine("{0} = {1}", reader.Name, reader.Value);
         }
         //Return the reader to the book element.
         reader.MoveToElement();
       }
     }

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

Imports System.IO
Imports System.Xml

Public Class Sample
    
    Public Shared Sub Main()
        Dim reader As XmlNodeReader = Nothing
        Try
            'Create and load the XML document.
            Dim doc As New XmlDocument()
            doc.LoadXml("<book genre='novel' ISBN='1-861003-78' publicationdate='1987'> " & _
                       "</book>")
            
            'Load the XmlNodeReader 
            reader = New XmlNodeReader(doc)
            
            'Read the attributes on the root element.
            reader.MoveToContent()
            If reader.HasAttributes Then
                Dim i As Integer
                For i = 0 To reader.AttributeCount - 1
                    reader.MoveToAttribute(i)
                    Console.WriteLine("{0} = {1}", reader.Name, reader.Value)
                Next i
                'Return the reader to the book element.
                reader.MoveToElement()
            End If
        
        Finally
            If Not (reader Is Nothing) Then
                reader.Close()
            End If
        End Try
    End Sub
End Class

설명

참고

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

적용 대상

MoveToAttribute(String)

지정된 이름이 있는 특성으로 이동합니다.

public:
 override bool MoveToAttribute(System::String ^ name);
public override bool MoveToAttribute (string name);
override this.MoveToAttribute : string -> bool
Public Overrides Function MoveToAttribute (name As String) As Boolean

매개 변수

name
String

특성의 정규화된 이름입니다.

반환

Boolean

특성이 있으면 true이고, 그렇지 않으면 false입니다. false이면, 판독기의 위치는 변경되지 않습니다.

설명

참고

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

이 메서드를 호출한 Name후 , NamespaceURIPrefix 속성은 해당 특성의 속성을 반영합니다.

적용 대상

MoveToAttribute(String, String)

지정된 로컬 이름과 네임스페이스 URI가 있는 특성으로 이동합니다.

public:
 override bool MoveToAttribute(System::String ^ name, System::String ^ namespaceURI);
public override bool MoveToAttribute (string name, string? namespaceURI);
public override bool MoveToAttribute (string name, string namespaceURI);
override this.MoveToAttribute : string * string -> bool
Public Overrides Function MoveToAttribute (name As String, namespaceURI As String) As Boolean

매개 변수

name
String

특성의 로컬 이름입니다.

namespaceURI
String

특성의 네임스페이스 URI입니다.

반환

Boolean

특성이 있으면 true이고, 그렇지 않으면 false입니다. false이면, 판독기의 위치는 변경되지 않습니다.

설명

참고

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

이 메서드를 호출한 Name후 , NamespaceURIPrefix 속성은 해당 특성의 속성을 반영합니다.

적용 대상