XmlNamedNodeMap.GetNamedItem 메서드

정의

XmlNode의 노드 컬렉션에서 지정된 XmlNamedNodeMap를 검색합니다.

오버로드

GetNamedItem(String)

이름으로 지정된 XmlNode를 검색합니다.

GetNamedItem(String, String)

일치하는 LocalNameNamespaceURI를 갖고 있는 노드를 검색합니다.

GetNamedItem(String)

이름으로 지정된 XmlNode를 검색합니다.

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

매개 변수

name
String

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

반환

XmlNode

지정된 이름을 가진 XmlNode이거나, 일치하는 노드가 없으면 null입니다.

예제

다음 예제에서는 클래스(상속XmlNamedNodeMap)를 사용하여 XmlAttributeCollection 특성을 수정합니다.

#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' publicationdate='1997'>   <title>Pride And Prejudice</title></book>" );
   XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes;
   
   // Change the value for the genre attribute.
   XmlAttribute^ attr = dynamic_cast<XmlAttribute^>(attrColl->GetNamedItem( "genre" ));
   attr->Value = "fiction";
   Console::WriteLine( "Display the modified XML..." );
   Console::WriteLine( doc->OuterXml );
}
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {
     XmlDocument doc = new XmlDocument();
     doc.LoadXml("<book genre='novel' publicationdate='1997'> " +
                 "  <title>Pride And Prejudice</title>" +
                 "</book>");

     XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;

     // Change the value for the genre attribute.
     XmlAttribute attr = (XmlAttribute)attrColl.GetNamedItem("genre");
     attr.Value = "fiction";

     Console.WriteLine("Display the modified XML...");
     Console.WriteLine(doc.OuterXml);
  }
}
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

    Dim doc as XmlDocument = new XmlDocument()
    doc.LoadXml("<book genre='novel' publicationdate='1997'> " & _
                "  <title>Pride And Prejudice</title>" & _
                "</book>")
                         
    Dim attrColl as XmlAttributeCollection = doc.DocumentElement.Attributes

    ' Change the value for the genre attribute.
    Dim attr as XmlAttribute = CType(attrColl.GetNamedItem("genre"),XmlAttribute)
    attr.Value = "fiction"

    Console.WriteLine("Display the modified XML...")
    Console.WriteLine(doc.OuterXml)
    
  end sub
end class

적용 대상

GetNamedItem(String, String)

일치하는 LocalNameNamespaceURI를 갖고 있는 노드를 검색합니다.

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

매개 변수

localName
String

검색할 노드의 로컬 이름입니다.

namespaceURI
String

검색할 노드의 네임스페이스 URI(Uniform Resource Identifier)입니다.

반환

XmlNode

일치하는 로컬 이름과 네임스페이스 URI를 갖고 있는 XmlNode이거나, 일치하는 노드가 없는 경우에는 null입니다.

적용 대상