html5中文学习网

您的位置: 首页 > 网络编程 > ASP.NET » 正文

XmlNodeList_.NET教程_编程技术

[ ] 已经帮助:人解决问题
xml
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.
 
EJyHTML5中文学习网 - HTML5先行者学习网
EJyHTML5中文学习网 - HTML5先行者学习网
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助