XmlAttributeCollection.ItemOf[] プロパティ

定義

指定した名前またはインデックスを持つ属性を取得します。

オーバーロード

名前 説明
ItemOf[Int32]

指定したインデックスを持つ属性を取得します。

ItemOf[String]

指定した名前の属性を取得します。

ItemOf[String, String]

指定したローカル名と名前空間の Uniform Resource Identifier (URI) を持つ属性を取得します。

ItemOf[Int32]

ソース:
XmlAttributeCollection.cs
ソース:
XmlAttributeCollection.cs
ソース:
XmlAttributeCollection.cs
ソース:
XmlAttributeCollection.cs
ソース:
XmlAttributeCollection.cs

指定したインデックスを持つ属性を取得します。

public:
 property System::Xml::XmlAttribute ^ default[int] { System::Xml::XmlAttribute ^ get(int i); };
public:
 virtual property System::Xml::XmlAttribute ^ default[int] { System::Xml::XmlAttribute ^ get(int i); };
public System.Xml.XmlAttribute this[int i] { get; }
public virtual System.Xml.XmlAttribute this[int i] { get; }
member this.ItemOf(int) : System.Xml.XmlAttribute
Default Public ReadOnly Property ItemOf(i As Integer) As XmlAttribute
Default Public Overridable ReadOnly Property ItemOf(i As Integer) As XmlAttribute

パラメーター

i
Int32

属性のインデックス。

プロパティ値

指定したインデックス位置にある属性。

例外

渡されるインデックスが範囲外です。

次の例では、コレクション内のすべての属性を表示します。

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

    //Create an attribute collection.
    XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;

    Console.WriteLine("Display all the attributes in the collection...\r\n");
    for (int i=0; i < attrColl.Count; i++)
    {
      Console.Write("{0} = ", attrColl[i].Name);
      Console.Write("{0}", attrColl[i].Value);
      Console.WriteLine();
    }
  }
}
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>")      

    'Create an attribute collection.
    Dim attrColl as XmlAttributeCollection = doc.DocumentElement.Attributes

    Console.WriteLine("Display all the attributes in the collection...")
    Dim i as integer
    for i=0  to attrColl.Count-1
      Console.Write("{0} = ", attrColl.ItemOf(i).Name)
      Console.Write("{0}", attrColl.ItemOf(i).Value)
      Console.WriteLine()
    next
        
  end sub
end class

注釈

このプロパティは、ドキュメント オブジェクト モデル (DOM) に対する Microsoft の拡張機能です。 これは、 XmlNamedNodeMap.Itemを呼び出すことと同じです。

こちらもご覧ください

適用対象

ItemOf[String]

ソース:
XmlAttributeCollection.cs
ソース:
XmlAttributeCollection.cs
ソース:
XmlAttributeCollection.cs
ソース:
XmlAttributeCollection.cs
ソース:
XmlAttributeCollection.cs

指定した名前の属性を取得します。

public:
 property System::Xml::XmlAttribute ^ default[System::String ^] { System::Xml::XmlAttribute ^ get(System::String ^ name); };
public:
 virtual property System::Xml::XmlAttribute ^ default[System::String ^] { System::Xml::XmlAttribute ^ get(System::String ^ name); };
public System.Xml.XmlAttribute this[string name] { get; }
public System.Xml.XmlAttribute? this[string name] { get; }
public virtual System.Xml.XmlAttribute this[string name] { get; }
member this.ItemOf(string) : System.Xml.XmlAttribute
Default Public ReadOnly Property ItemOf(name As String) As XmlAttribute
Default Public Overridable ReadOnly Property ItemOf(name As String) As XmlAttribute

パラメーター

name
String

属性の修飾名。

プロパティ値

指定した名前の属性。 属性が存在しない場合、このプロパティは 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>");

    //Create an attribute collection and remove an attribute
    //from the collection.
    XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;
    attrColl.Remove(attrColl["genre"]);

    Console.WriteLine("Display the modified XML...\r\n");
    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' ISBN='1-861001-57-5'>" & _
                "<title>Pride And Prejudice</title>" & _
                "</book>")      

    'Create an attribute collection and remove an attribute
    'from the collection.  
    Dim attrColl as XmlAttributeCollection = doc.DocumentElement.Attributes
    attrColl.Remove(attrColl.ItemOf("genre"))

    Console.WriteLine("Display the modified XML...")
    Console.WriteLine(doc.OuterXml)

  end sub
end class

注釈

このプロパティは、ドキュメント オブジェクト モデル (DOM) に対する Microsoft の拡張機能です。 これは、 GetNamedItemを呼び出すことと同じです。

適用対象

ItemOf[String, String]

ソース:
XmlAttributeCollection.cs
ソース:
XmlAttributeCollection.cs
ソース:
XmlAttributeCollection.cs
ソース:
XmlAttributeCollection.cs
ソース:
XmlAttributeCollection.cs

指定したローカル名と名前空間の Uniform Resource Identifier (URI) を持つ属性を取得します。

public:
 property System::Xml::XmlAttribute ^ default[System::String ^, System::String ^] { System::Xml::XmlAttribute ^ get(System::String ^ localName, System::String ^ namespaceURI); };
public:
 virtual property System::Xml::XmlAttribute ^ default[System::String ^, System::String ^] { System::Xml::XmlAttribute ^ get(System::String ^ localName, System::String ^ namespaceURI); };
public System.Xml.XmlAttribute this[string localName, string namespaceURI] { get; }
public System.Xml.XmlAttribute? this[string localName, string? namespaceURI] { get; }
public virtual System.Xml.XmlAttribute this[string localName, string namespaceURI] { get; }
member this.ItemOf(string * string) : System.Xml.XmlAttribute
Default Public ReadOnly Property ItemOf(localName As String, namespaceURI As String) As XmlAttribute
Default Public Overridable ReadOnly Property ItemOf(localName As String, namespaceURI As String) As XmlAttribute

パラメーター

localName
String

属性のローカル名。

namespaceURI
String

属性の名前空間 URI。

プロパティ値

指定されたローカル名と名前空間 URI を持つ属性。 属性が存在しない場合、このプロパティは nullを返します。

注釈

このプロパティは、ドキュメント オブジェクト モデル (DOM) に対する Microsoft の拡張機能です。 これは、 GetNamedItemを呼び出すことと同じです。

適用対象