Tutorials
XMLIn this first tutorial of his series on using scripting languages to manipulate and transform XML documents, Binary Evolution's Parand Tony Daruger takes you through the first steps of using these techniques with Perl. You'll see a method for transforming XML to HTML, followed by a simple stock-trading application that uses Perl, XML, and a database to evaluate trading rules. You can apply the techniques using other scripting languages too, including Tcl and Python.
XML and scripting languages have had a natural relationship since the early days of XML's inception. One of the original goals of the XML design group was to enable a Perl hacker to write an XML parser in two weeks. Handling and manipulating XML has also been fertile ground for using scripting with XML: XML is designed to be human legible, and thus mainly text based. Scripting languages have historically been extremely adept at manipulating text. Scripting's flexibility and power make it a perfect complement to XML's descriptive abilities.
XML is a medium for the expression, storage, and exchange of information. The addition of scripting allows this information to become active: to affect actions, undergo transformations, connect with existing systems, and take action instead of simply expressing information.
In this article we will use Perl to manipulate and transform XML. You can apply the same techniques using other scripting languages too, including Tcl and Python. First a technique for transformation of XML to HTML will be shown, followed by a simple stock trading application that uses Perl, XML, and a database to evaluate trading rules.