Scriptol/Xml or class
Xml or class
editCommon class
editScriptol is object-oriented and has classes and inheritance. Defining a class is easy. Example of a very simple class.
class car int speed void getSpeed() ... some statements ... return speed /class
Xml
editBut Scriptol has also xml. Defining a xml document is simple also.
xml Car speed value = "10" / wheels number = "4" passengers number = "5" Clara, Charly, Corinna, Cyril, Cecilia /passengers /xml
Using Xml
editClasses are used directly or by creating an instance, and making reference to attributes or calls to methods.
Using Xml is not different. You can define how many instances of xml documents you want, and modify the content of each of them. The content of elements or attributes may be assigned, and elements and attributes may be added of removed.
Car myCar ` myCar is an instance of the Car Xml document. print myCar.speed ` displaying the value of the "speed" attribute. print myCar.passengers ` displaying the content of the "passengers" tag.
Importing xml document
editXml is mainly useful for performing processes on documents produced by various tools, word processors, spreadsheets, etc....
To load such documents, Scriptol integrates a sax parser. You have just to declare a xml document, load le xml file, and you can use the document as a class declared in the source.
xml Car ` declaring an empty xml document. /xml
Car myCar` defining an instance (not required). myCar.load("document.xml") ` loading an external xml document
Car.load("document.xml") ` you can use directly the xml class itself
Iterator
editIterator on xml document is as iterator on array, plus the down() and up() methods. Iterator allows to parse an entire xml document or just sub-elements of of an element.
demo.begin() while demo.isFound() print demo.getData() let demo.inc()