Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

XmlNamedNodeMap::GetNamedItem Method (String^)

 

Retrieves an XmlNode specified by name.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public:
virtual XmlNode^ GetNamedItem(
	String^ name
)

Parameters

name
Type: System::String^

The qualified name of the node to retrieve. It is matched against the Name property of the matching node.

Return Value

Type: System.Xml::XmlNode^

An XmlNode with the specified name or null if a matching node is not found.

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 );
}

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top
Show:
© 2017 Microsoft