XmlElement.GetAttributeNode Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Retournez le XmlAttribute.
Surcharges
| Nom | Description |
|---|---|
| GetAttributeNode(String) |
Retourne le |
| GetAttributeNode(String, String) |
Retourne le nom local et l’URI XmlAttribute d’espace de noms spécifiés. |
GetAttributeNode(String)
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
Retourne le XmlAttribute nom spécifié.
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
Paramètres
- name
- String
Nom de l’attribut à récupérer. Il s’agit d’un nom qualifié. Il est mis en correspondance avec la Name propriété du nœud correspondant.
Retours
Spécifié XmlAttribute ou null si un attribut correspondant n’a pas été trouvé.
Exemples
L’exemple suivant vérifie si l’élément a l’attribut spécifié.
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
S’applique à
GetAttributeNode(String, String)
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
Retourne le nom local et l’URI XmlAttribute d’espace de noms spécifiés.
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
Paramètres
- localName
- String
Nom local de l’attribut.
- namespaceURI
- String
URI d’espace de noms de l’attribut.
Retours
Spécifié XmlAttribute ou null si un attribut correspondant n’a pas été trouvé.