XmlNode.Item[] Właściwość

Definicja

Pobiera określony element podrzędny.

Przeciążenia

Item[String]

Pobiera pierwszy element podrzędny z określonym Nameelementem .

Item[String, String]

Pobiera pierwszy element podrzędny z określonymi LocalName elementami i NamespaceURI.

Item[String]

Pobiera pierwszy element podrzędny z określonym Nameelementem .

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

Parametry

name
String

Kwalifikowana nazwa elementu do pobrania.

Wartość właściwości

XmlElement

Pierwszy XmlElement , który jest zgodny z określoną nazwą. Zwraca odwołanie o wartości null (Nothingw Visual Basic), jeśli nie ma dopasowania.

Przykłady

W poniższym przykładzie zostanie wyświetlony element tytułu.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;

int main()
{
   XmlDocument^ doc = gcnew 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 );
}
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

Uwagi

Ta właściwość jest rozszerzeniem firmy Microsoft do modelu obiektów dokumentów (DOM).

Dotyczy

Item[String, String]

Pobiera pierwszy element podrzędny z określonymi LocalName elementami i NamespaceURI.

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

Parametry

localname
String

Lokalna nazwa elementu.

ns
String

Identyfikator URI przestrzeni nazw elementu.

Wartość właściwości

XmlElement

Pierwszy XmlElement z pasującymi localname elementami i ns. Zwraca odwołanie o wartości null (Nothingw Visual Basic), jeśli nie ma dopasowania.

Uwagi

Ta właściwość jest rozszerzeniem firmy Microsoft do modelu obiektów dokumentów (DOM).

Dotyczy