XmlElement.GetAttributeNode Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Devolve o especificado XmlAttribute.
Sobrecargas
| Name | Description |
|---|---|
| GetAttributeNode(String) |
Devolve o |
| GetAttributeNode(String, String) |
Devolve o XmlAttribute com o nome local especificado e o URI do espaço de nomes. |
GetAttributeNode(String)
- Origem:
- XmlElement.cs
- Origem:
- XmlElement.cs
- Origem:
- XmlElement.cs
- Origem:
- XmlElement.cs
- Origem:
- XmlElement.cs
Devolve o XmlAttribute com o nome especificado.
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
Parâmetros
- name
- String
O nome do atributo a recuperar. Este é um nome qualificado. É comparado com a Name propriedade do nó correspondente.
Devoluções
O especificado XmlAttribute ou null se não foi encontrado um atributo correspondente.
Exemplos
O exemplo seguinte verifica se o elemento tem o atributo especificado.
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
Aplica-se a
GetAttributeNode(String, String)
- Origem:
- XmlElement.cs
- Origem:
- XmlElement.cs
- Origem:
- XmlElement.cs
- Origem:
- XmlElement.cs
- Origem:
- XmlElement.cs
Devolve o XmlAttribute com o nome local especificado e o URI do espaço de nomes.
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
Parâmetros
- localName
- String
O nome local do atributo.
- namespaceURI
- String
O URI do namespace do atributo.
Devoluções
O especificado XmlAttribute ou null se não foi encontrado um atributo correspondente.