XmlNamedNodeMap.GetNamedItem Método
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Recupera o especificado XmlNode da coleção de nós no XmlNamedNodeMap.
Sobrecargas
| Nome | Description |
|---|---|
| GetNamedItem(String) |
Recupera um XmlNode especificado por nome. |
| GetNamedItem(String, String) |
Recupera um nó com a correspondência LocalName e NamespaceURI. |
GetNamedItem(String)
- Origem:
- XmlNamedNodemap.cs
- Origem:
- XmlNamedNodemap.cs
- Origem:
- XmlNamedNodemap.cs
- Origem:
- XmlNamedNodemap.cs
- Origem:
- XmlNamedNodemap.cs
Recupera um XmlNode especificado por nome.
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
Parâmetros
- name
- String
O nome qualificado do nó a ser recuperado. Ele é correspondido com a Name propriedade do nó correspondente.
Retornos
Um XmlNode com o nome especificado ou null se um nó correspondente não for encontrado.
Exemplos
O exemplo a seguir usa a XmlAttributeCollection classe (que herda de XmlNamedNodeMap) para modificar um atributo.
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
Aplica-se a
GetNamedItem(String, String)
- Origem:
- XmlNamedNodemap.cs
- Origem:
- XmlNamedNodemap.cs
- Origem:
- XmlNamedNodemap.cs
- Origem:
- XmlNamedNodemap.cs
- Origem:
- XmlNamedNodemap.cs
Recupera um nó com a correspondência LocalName e NamespaceURI.
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
Parâmetros
- localName
- String
O nome local do nó a ser recuperado.
- namespaceURI
- String
O URI (Uniform Resource Identifier) do namespace do nó a ser recuperado.
Retornos
Um XmlNode com o nome local correspondente e o URI do namespace ou null se um nó correspondente não foi encontrado.