XmlNode.Item[] Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the specified child element.
Overloads
Item[String] |
Gets the first child element with the specified Name. |
Item[String, String] |
Gets the first child element with the specified LocalName and NamespaceURI. |
Item[String]
- Source:
- XmlNode.cs
- Source:
- XmlNode.cs
- Source:
- XmlNode.cs
Gets the first child element with the specified 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
Parameters
- name
- String
The qualified name of the element to retrieve.
Property Value
The first XmlElement that matches the specified name. It returns a null reference (Nothing
in Visual Basic) if there is no match.
Examples
The following example displays the title element.
#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
Remarks
This property is a Microsoft extension to the Document Object Model (DOM).
Applies to
Item[String, String]
- Source:
- XmlNode.cs
- Source:
- XmlNode.cs
- Source:
- XmlNode.cs
Gets the first child element with the specified LocalName and 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
Parameters
- localname
- String
The local name of the element.
- ns
- String
The namespace URI of the element.
Property Value
The first XmlElement with the matching localname
and ns
. It returns a null reference (Nothing
in Visual Basic) if there is no match.
Remarks
This property is a Microsoft extension to the Document Object Model (DOM).
Applies to
Atsauksmes
https://aka.ms/ContentUserFeedback.
Drīzumā: 2024. gada laikā mēs pakāpeniski pārtrauksim izmantot “GitHub problēmas” kā atsauksmju par saturu mehānismu un aizstāsim to ar jaunu atsauksmju sistēmu. Papildinformāciju skatiet:Iesniegt un skatīt atsauksmes par