XmlNodeList

发表于:2007-06-30来源:作者:点击数: 标签:
Returns an XmlNodeList containing a list of all descend ant elements that match the specified name. Overload List Returns an XmlNodeList containing a list of all descendant elements that match the specified Name. [Visual Basic] Overloads Ov
Returns an XmlNodeList containing a list of all descendant elements that match the specified name.

Overload List
Returns an XmlNodeList containing a list of all descendant elements that match the specified Name.

[Visual Basic] Overloads Overridable Public Function GetElementsByTagName(String) As XmlNodeList
[C#] public virtual XmlNodeList GetElementsByTagName(string);
[C++] public: virtual XmlNodeList* GetElementsByTagName(String*);
[JScript] public function GetElementsByTagName(String) : XmlNodeList;
Returns an XmlNodeList containing a list of all descendant elements that match the specified LocalName and NamespaceURI.

[Visual Basic] Overloads Overridable Public Function GetElementsByTagName(String, String) As XmlNodeList
[C#] public virtual XmlNodeList GetElementsByTagName(string, string);
[C++] public: virtual XmlNodeList* GetElementsByTagName(String*, String*);
[JScript] public function GetElementsByTagName(String, String) : XmlNodeList;
Example
[Visual Basic, C#] The following example creates a XmlDocument object and uses the GetElmentsByTagName method and the resulting XmlNodeList object to display all the book titles.

[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of GetElementsByTagName. For other examples that may be available, see the individual overload topics.
[Visual Basic]
Option Explicit
Option Strict

Imports System
Imports System.IO
Imports System.Xml

Public Class Sample
    
    Public Shared Sub Main()
        @#Create the XmlDocument.
        Dim doc As New XmlDocument()
        doc.Load("books.xml")
        
        @#Display all the book titles.
        Dim elemList As XmlNodeList = doc.GetElementsByTagName("title")
        Dim i As Integer
        For i = 0 To elemList.Count - 1
            Console.WriteLine(elemList(i).InnerXml)
        Next i
    End Sub @#Main
End Class @#Sample
[C#]


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

public class Sample
{
  public static void Main()
  {
    //Create the XmlDocument.
    XmlDocument doc = new XmlDocument();
    doc.Load("books.xml");

    //Display all the book titles.
    XmlNodeList elemList = doc.GetElementsByTagName("title");
    for (int i=0; i < elemList.Count; i++)
    {   
      Console.WriteLine(elemList[i].InnerXml);
    }  

  }
}
[C++, JScript] No example is available in C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button  in the upper-left corner of the page.
 

原文转自:http://www.ltesting.net