ECMA-357 Specification (PDF) | Rhino Javascript implementation
var phoneBook = <phoneBook>
<phoneEntry>
<name>Joe Schwartz</name>
<phoneNumber>342-2351</phoneNumber>
</phoneEntry>
</phoneBook>
var phoneBook = new XML(phoneBookStr);
var a = "bar";
var data = <foo id={a+(3+4)}>{a+" "+"bat"}</foo>;
print(data); // => <foo id="bar7">bar bat</foo>
var phoneBook = <phoneBook>
<phoneEntry>
<name>Joe Schwartz</name>
<phoneNumber>342-2351</phoneNumber>
</phoneEntry>
</phoneBook>;
var phoneBookStr = phoneBook.toXMLString();
/*
=> "<phoneBook>
<phoneEntry>
<name>Joe Schwartz</name>
<phoneNumber>342-2351</phoneNumber>
</phoneEntry>
</phoneBook>"
*/
var phoneBook = <phoneBook>
<phoneEntry>
<name>Joe Schwartz</name>
<phoneNumber>342-2351</phoneNumber>
</phoneEntry>
<phoneEntry>
<name>Aleria Delamare</name>
<phoneNumber>342-7721</phoneNumber>
</phoneEntry>
<phoneEntry>
<name>Susan Sto Helit</name>
<phoneNumber>315-2987</phoneNumber>
</phoneEntry>
<phoneEntry>
<name>Kyle Martin</name>
<phoneNumber>342-7219</phoneNumber>
</phoneEntry>
</phoneBook>
print(phoneBook.phoneEntry.length()); // =>4
print(phoneBook.phoneEntry[0]);
/*
=>
<phoneEntry>
<name>Joe Schwartz</name>
<phoneNumber>342-2351</phoneNumber>
</phoneEntry>
*/
var entry0 = phoneBook["phoneEntry"][0];
print(entry0.name); // => "Joe Schwartz"
print(entry0["name"]); // => "Joe Schwartz"
Last modified 16 December 2024