XmlElement.GetAttributeNode メソッド

定義

指定した XmlAttributeを返します。

オーバーロード

名前 説明
GetAttributeNode(String)

指定した名前の XmlAttribute を返します。

GetAttributeNode(String, String)

指定したローカル名と名前空間 URI を持つ XmlAttribute を返します。

GetAttributeNode(String)

ソース:
XmlElement.cs
ソース:
XmlElement.cs
ソース:
XmlElement.cs
ソース:
XmlElement.cs
ソース:
XmlElement.cs

指定した名前の XmlAttribute を返します。

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

パラメーター

name
String

取得する属性の名前。 これは修飾名です。 一致するノードの Name プロパティと照合されます。

返品

一致する属性が見つからなかった場合は、指定した XmlAttribute または null

次の例では、要素に指定された属性があるかどうかを確認します。

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

適用対象

GetAttributeNode(String, String)

ソース:
XmlElement.cs
ソース:
XmlElement.cs
ソース:
XmlElement.cs
ソース:
XmlElement.cs
ソース:
XmlElement.cs

指定したローカル名と名前空間 URI を持つ XmlAttribute を返します。

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

パラメーター

localName
String

属性のローカル名。

namespaceURI
String

属性の名前空間 URI。

返品

一致する属性が見つからなかった場合は、指定した XmlAttribute または null

適用対象