|
|||||||
|
27.05.2005
by Wolfgang Schmidetzki
Rhino Javascript Engine Supports ECMAScript for XML (E4X) Categories: tmlscript
The Rhino Scripting Engine from Mozilla is an open-source implementation of JavaScript written
entirely in Java. It gives us serverside javascript in
Java applications. Innovation Gate integreated Rhino in its Content
Management System WebGate AnyWhere.
The new Rhino version (integrated in WebGate Anywhere 3.2) supports E4X, which is a very cool way to handle XML in javascript.
Some examples: // Use an XML literal to create an XML object var order = <order> <customer> <firstname>John</firstname> <lastname>Doe</lastname> </customer> <item> <description>Big Screen Television</description> <price>1299.99</price> <quantity>1</quantity> </item> </order> var name = order.customer.firstname + " " + order.customer.lastname; // construct a new XML object using expando and super-expando properties var order = <order/>; order.customer.name = "Fred Jones"; order.customer.address.street = "123 Long Lang"; order.customer.address.city = "Underwood"; order.customer.address.state = "CA"; order.item[0] = ""; order.item[0].description = "Small Rodents"; order.item[0].quantity = 10; order.item[0].price = 6.95; Find more examples here. |
Syndicate
Dokumentationen
© Innovation Gate
|
||||||