Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Iterate over Child NodesDownloads for Windows/Linux and Install Instructions Iterate over the children of an XML node. # file: xmlChildIterate.rb
#
# Iterate over child nodes in a document using FirstChild/NextSibling.
require 'rubygems'
require 'chilkat'
# The Chilkat XML parser for Ruby is freeware. The code demonstrated in this
# example can be used in both commercial and non-commercial applications without
# restriction.
# The Chilkat XML Ruby examples utilize these online XML data samples:
# http://www.chilkatsoft.com/xml-samples/bookstore.xml
# http://www.chilkatsoft.com/xml-samples/nutrition.xml
# http://www.chilkatsoft.com/xml-samples/pigs.xml
# http://www.chilkatsoft.com/xml-samples/plants.xml
# http://www.chilkatsoft.com/xml-samples/japanese.xml
# http://www.chilkatsoft.com/xml-samples/hamlet.xml
xml = Chilkat::CkXml.new()
xml.LoadXmlFile("plants.xml")
# Iterate over each "PLANT" under the "CATALOG" node.
# (The CATALOG node is the root node of the document...)
commonName = Chilkat::CkString.new()
plant = xml.FirstChild()
while plant != nil
plant.GetChildContent("COMMON",commonName)
print commonName.getString() + "\n"
plant = plant.NextSibling()
end
|
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.