Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project











METHOD:  Element::getElementsByTagName

Element.getElementsByTagName(name)

The getElementsByTagName method returns a NodeList of all descendant elements of the specified name. If you supply the three characters "*" as the argument to this method, it returns all descendant elements of whatever name.

In the following example using the 'albums.xml' file the code creates a NodeList of all the 'artist' elements, and then iterates through it displaying the nodeValue of the firstChild of each (the text).

XML:
<Albums>
   <Album ref="CD142" category="Folk">
      <title>Boil The Breakfast Early</title>
      <artist>The Chieftains</artist>
   </Album>
   <Album ref="CD720" category="Pop">
      <title>Come On Over</title>
      <artist>Shania Twain</artist>
   </Album>
   <Album ref="CD024" category="Country">
      <title>Red Dirt Girl</title>
      <artist>Emmylou Harris</artist>
   </Album>
</Albums>

Code (VBScript):
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("albums.xml")

Set Root = objXMLDoc.documentElement
Set NodeList = Root.getElementsByTagName("artist")
For Each Elem In NodeList
   document.write(Elem.firstChild.nodeValue & "<br>")
Next

Output:
The Chieftains
Shania Twain
Emmylou Harris



 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information