XmlElement.GetElementsByTagName 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정한 XmlNodeList 이름과 일치하는 모든 하위 요소의 목록을 포함하는 반환합니다.
오버로드
| Name | Description |
|---|---|
| GetElementsByTagName(String, String) |
XmlNodeList 지정된 LocalName 요소와 일치하는 모든 하위 요소의 목록을 포함하는 반환합니다NamespaceURI. |
| GetElementsByTagName(String) |
XmlNodeList 지정된 Name요소와 일치하는 모든 하위 요소의 목록을 포함하는 반환합니다. |
GetElementsByTagName(String, String)
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
XmlNodeList 지정된 LocalName 요소와 일치하는 모든 하위 요소의 목록을 포함하는 반환합니다NamespaceURI.
public:
virtual System::Xml::XmlNodeList ^ GetElementsByTagName(System::String ^ localName, System::String ^ namespaceURI);
public virtual System.Xml.XmlNodeList GetElementsByTagName(string localName, string namespaceURI);
abstract member GetElementsByTagName : string * string -> System.Xml.XmlNodeList
override this.GetElementsByTagName : string * string -> System.Xml.XmlNodeList
Public Overridable Function GetElementsByTagName (localName As String, namespaceURI As String) As XmlNodeList
매개 변수
- localName
- String
일치시킬 로컬 이름입니다. 별표(*)는 모든 태그와 일치하는 특수 값입니다.
- namespaceURI
- String
일치시킬 네임스페이스 URI입니다.
반품
XmlNodeList 일치하는 모든 노드의 목록을 포함하는 항목입니다. 일치하는 노드가 없으면 목록이 비어 있습니다.
설명
노드는 트리의 사전 순서 이동 XmlElement 에서 발생하는 순서대로 배치됩니다.
메모
메서드 대신 XmlNode.SelectNodes 또는 XmlNode.SelectSingleNode 메서드를 GetElementsByTagName 사용하는 것이 좋습니다.
적용 대상
GetElementsByTagName(String)
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
XmlNodeList 지정된 Name요소와 일치하는 모든 하위 요소의 목록을 포함하는 반환합니다.
public:
virtual System::Xml::XmlNodeList ^ GetElementsByTagName(System::String ^ name);
public virtual System.Xml.XmlNodeList GetElementsByTagName(string name);
abstract member GetElementsByTagName : string -> System.Xml.XmlNodeList
override this.GetElementsByTagName : string -> System.Xml.XmlNodeList
Public Overridable Function GetElementsByTagName (name As String) As XmlNodeList
매개 변수
- name
- String
일치시킬 이름 태그입니다. 정규화된 이름입니다. 일치하는 노드의 속성과 Name 일치합니다. 별표(*)는 모든 태그와 일치하는 특수 값입니다.
반품
XmlNodeList 일치하는 모든 노드의 목록을 포함하는 항목입니다. 일치하는 노드가 없으면 목록이 비어 있습니다.
예제
다음 예제에서는 모든 책 제목을 가져오고 표시합니다.
using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main()
{
XmlDocument doc = new XmlDocument();
doc.Load("2books.xml");
// Get and display all the book titles.
XmlElement root = doc.DocumentElement;
XmlNodeList elemList = root.GetElementsByTagName("title");
for (int i=0; i < elemList.Count; i++)
{
Console.WriteLine(elemList[i].InnerXml);
}
}
}
Imports System.IO
Imports System.Xml
public class Sample
public shared sub Main()
Dim doc as XmlDocument = new XmlDocument()
doc.Load("2books.xml")
' Get and display all the book titles.
Dim root as XmlElement = doc.DocumentElement
Dim elemList as XmlNodeList = root.GetElementsByTagName("title")
Dim i as integer
for i=0 to elemList.Count-1
Console.WriteLine(elemList.ItemOf(i).InnerXml)
next
end sub
end class
이 예제에서는 파일을 2books.xml입력으로 사용합니다.
<!--sample XML fragment-->
<bookstore>
<book genre='novel' ISBN='10-861003-324'>
<title>The Handmaid's Tale</title>
<price>19.95</price>
</book>
<book genre='novel' ISBN='1-861001-57-5'>
<title>Pride And Prejudice</title>
<price>24.95</price>
</book>
</bookstore>
설명
노드는 트리의 사전 순서 이동 XmlElement 에서 발생하는 순서대로 배치됩니다.
메모
메서드 대신 XmlNode.SelectNodes 또는 XmlNode.SelectSingleNode 메서드를 GetElementsByTagName 사용하는 것이 좋습니다.