XmlNamedNodeMap.GetNamedItem Method

Definition

XmlNode의 노드 컬렉션에서 지정된 XmlNamedNodeMap를 검색합니다.Retrieves the specified XmlNode from the collection of nodes in the XmlNamedNodeMap.

Overloads

GetNamedItem(String)

이름으로 지정된 XmlNode를 검색합니다.Retrieves an XmlNode specified by name.

GetNamedItem(String, String)

일치하는 LocalNameNamespaceURI를 갖고 있는 노드를 검색합니다.Retrieves a node with the matching LocalName and NamespaceURI.

GetNamedItem(String)

이름으로 지정된 XmlNode를 검색합니다.Retrieves an XmlNode specified by name.

public:
 virtual System::Xml::XmlNode ^ GetNamedItem(System::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

Parameters

name
String

검색할 노드의 정규화 된 이름입니다.The qualified name of the node to retrieve. 일치하는 노드의 Name 속성과 일치합니다.It is matched against the Name property of the matching node.

Returns

XmlNode

지정된 이름을 가진 XmlNode이거나, 일치하는 노드가 없으면 null입니다.An XmlNode with the specified name or null if a matching node is not found.

Examples

다음 예제에서는 XmlNamedNodeMap에서 상속 되는 XmlAttributeCollection 클래스를 사용 하 여 특성을 수정 합니다.The following example uses the XmlAttributeCollection class (which inherits from XmlNamedNodeMap) to modify an attribute.

#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를 갖고 있는 노드를 검색합니다.Retrieves a node with the matching LocalName and NamespaceURI.

public:
 virtual System::Xml::XmlNode ^ GetNamedItem(System::String ^ localName, System::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

Parameters

localName
String

검색할 노드의 로컬 이름입니다.The local name of the node to retrieve.

namespaceURI
String

네임 스페이스 식별자 URI (Uniform Resource) 노드를 검색 합니다.The namespace Uniform Resource Identifier (URI) of the node to retrieve.

Returns

XmlNode

일치하는 로컬 이름과 네임스페이스 URI를 갖고 있는 XmlNode이거나, 일치하는 노드가 없는 경우에는 null입니다.An XmlNode with the matching local name and namespace URI or null if a matching node was not found.

Applies to