XmlNode.Item[] プロパティ

定義

指定した子要素を取得します。

オーバーロード

名前 説明
Item[String]

指定した Nameを持つ最初の子要素を取得します。

Item[String, String]

指定した LocalNameNamespaceURIを持つ最初の子要素を取得します。

Item[String]

ソース:
XmlNode.cs
ソース:
XmlNode.cs
ソース:
XmlNode.cs
ソース:
XmlNode.cs
ソース:
XmlNode.cs

指定した Nameを持つ最初の子要素を取得します。

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

パラメーター

name
String

取得する要素の修飾名。

プロパティ値

指定した名前と一致する最初の XmlElement 。 一致しない場合は、null 参照 (Visual Basic では Nothing) が返されます。

次の例では、タイトル要素を表示します。

using System;
using System.IO;
using System.Xml;

public class Sample {

  public static void Main() {

    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<book ISBN='1-861001-57-5'>" +
                "<title>Pride And Prejudice</title>" +
                "<price>19.95</price>" +
                "</book>");

    XmlNode root = doc.FirstChild;

    Console.WriteLine("Display the title element...");
    Console.WriteLine(root["title"].OuterXml);
  }
}
Option Explicit
Option Strict

Imports System.IO
Imports System.Xml

Public Class Sample
    Public Shared Sub Main()
        
        Dim doc As New XmlDocument()
        doc.LoadXml("<book ISBN='1-861001-57-5'>" & _
                    "<title>Pride And Prejudice</title>" & _ 
                    "<price>19.95</price>" & _ 
                    "</book>")

        Dim root As XmlNode = doc.FirstChild
        Console.WriteLine("Display the title element...")
        Console.WriteLine(root("title").OuterXml)
    End Sub
End Class

注釈

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

適用対象

Item[String, String]

ソース:
XmlNode.cs
ソース:
XmlNode.cs
ソース:
XmlNode.cs
ソース:
XmlNode.cs
ソース:
XmlNode.cs

指定した LocalNameNamespaceURIを持つ最初の子要素を取得します。

public:
 virtual property System::Xml::XmlElement ^ default[System::String ^, System::String ^] { System::Xml::XmlElement ^ get(System::String ^ localname, System::String ^ ns); };
public virtual System.Xml.XmlElement this[string localname, string ns] { get; }
public virtual System.Xml.XmlElement? this[string localname, string ns] { get; }
member this.Item(string * string) : System.Xml.XmlElement
Default Public Overridable ReadOnly Property Item(localname As String, ns As String) As XmlElement

パラメーター

localname
String

要素のローカル名。

ns
String

要素の名前空間 URI。

プロパティ値

一致するXmlElementlocalnameを含む最初のns。 一致しない場合は、null 参照 (Visual Basic では Nothing) が返されます。

注釈

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

適用対象