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
|
(Python) XML Parsing Example: Currency DataSimple example showing how to parse an XML file containing currency data.
import sys import chilkat xml = chilkat.CkXml() # The Chilkat XML component is freeware. # Load an XML document. # This file is available at http://www.chilkatsoft.com/testData/currency.xml success = xml.LoadXmlFile("c:/myXmlFiles/currency.xml") if (success != True): print xml.lastErrorText() sys.exit() # Iterate over each "CURRENCY" child node and display the contents: n = xml.NumChildrenHavingTag("CURRENCY") for i in range(0,n): # curr is a CkXml curr = xml.GetNthChildWithTag("CURRENCY",i) print "----" print "Name: " + curr.getChildContent("NAME") print "Code: " + curr.getChildContent("CURRENCYCODE") print "Country: " + curr.getChildContent("COUNTRY") |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.