XmlElement.GetAttributeNode 메서드

정의

지정된 XmlAttribute를 반환합니다.

오버로드

GetAttributeNode(String)

지정된 이름의 XmlAttribute를 반환합니다.

GetAttributeNode(String, String)

지정된 로컬 이름과 네임스페이스 URI를 갖고 있는 XmlAttribute를 반환합니다.

GetAttributeNode(String)

지정된 이름의 XmlAttribute를 반환합니다.

public:
 virtual System::Xml::XmlAttribute ^ GetAttributeNode(System::String ^ name);
public virtual System.Xml.XmlAttribute GetAttributeNode (string name);
public virtual System.Xml.XmlAttribute? GetAttributeNode (string name);
abstract member GetAttributeNode : string -> System.Xml.XmlAttribute
override this.GetAttributeNode : string -> System.Xml.XmlAttribute
Public Overridable Function GetAttributeNode (name As String) As XmlAttribute

매개 변수

name
String

검색할 특성의 이름입니다. 정규화된 이름입니다. 일치하는 노드의 Name 속성과 일치합니다.

반환

XmlAttribute

지정된 XmlAttribute이거나 일치하는 특성이 없는 경우에는 null입니다.

예제

다음 예제에서는 요소에 지정된 특성이 있는지 확인합니다.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlDocument^ doc = gcnew XmlDocument;
   doc->LoadXml( "<book genre='novel' ISBN='1-861001-57-5'><title>Pride And Prejudice</title></book>" );
   XmlElement^ root = doc->DocumentElement;
   
   // Check to see if the element has a genre attribute.
   if ( root->HasAttribute( "genre" ) )
   {
      XmlAttribute^ attr = root->GetAttributeNode( "genre" );
      Console::WriteLine( attr->Value );
   }
}
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {

    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
                "<title>Pride And Prejudice</title>" +
                "</book>");

    XmlElement root = doc.DocumentElement;

    // Check to see if the element has a genre attribute.
    if (root.HasAttribute("genre")){
      XmlAttribute attr = root.GetAttributeNode("genre");
      Console.WriteLine(attr.Value);
   }
  }
}
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

    Dim doc as XmlDocument = new XmlDocument()
    doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" & _
                "<title>Pride And Prejudice</title>" & _
                "</book>")      

    Dim root as XmlElement = doc.DocumentElement

    ' Check to see if the element has a genre attribute.
    if (root.HasAttribute("genre"))
     Dim attr as XmlAttribute = root.GetAttributeNode("genre")
     Console.WriteLine(attr.Value)
    end if
       
    Console.WriteLine("Display the modified XML...")
    Console.WriteLine(doc.InnerXml)

  end sub
end class

적용 대상

GetAttributeNode(String, String)

지정된 로컬 이름과 네임스페이스 URI를 갖고 있는 XmlAttribute를 반환합니다.

public:
 virtual System::Xml::XmlAttribute ^ GetAttributeNode(System::String ^ localName, System::String ^ namespaceURI);
public virtual System.Xml.XmlAttribute GetAttributeNode (string localName, string namespaceURI);
public virtual System.Xml.XmlAttribute? GetAttributeNode (string localName, string? namespaceURI);
abstract member GetAttributeNode : string * string -> System.Xml.XmlAttribute
override this.GetAttributeNode : string * string -> System.Xml.XmlAttribute
Public Overridable Function GetAttributeNode (localName As String, namespaceURI As String) As XmlAttribute

매개 변수

localName
String

특성의 로컬 이름입니다.

namespaceURI
String

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

반환

XmlAttribute

지정된 XmlAttribute이거나 일치하는 특성이 없는 경우에는 null입니다.

적용 대상