Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Scriptol/Xml or class

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Xml or class Common class Scriptol 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 But 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 Classes 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 Xml 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 Iterator 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()