ECMA Script for XML (E4X) Interview Preparation Guide
Refine your E4X interview skills with our 8 critical questions. Each question is designed to test and expand your E4X expertise. Suitable for all experience levels, these questions will help you prepare thoroughly. Access the free PDF to get all 8 questions and give yourself the best chance of acing your E4X interview. This resource is perfect for thorough preparation and confidence building.8 E4X Questions and Answers:
1 :: How to use of E4X with XML?
Using E4X we can easily use JAvAScript with an XML.
Example:
I have written an XML document.
<order>
<date>2009-26-01</date>
<customer>
<firstname>Porus</firstname>
<lastname>Jain</lastname>
</customer>
<item>
<name>Milk</name>
<qty>4</qty>
<price>100.00</price>
</item>
</order>
We can stroe this XML document as an string in variable order.
var order = new XML(txt)
'or'
Assign the XML text to the XML object variable directly.
var order = new XML()
order=<order id="010">
<date>2009-26-01</date>
<customer>
<firstname>Porus</firstname>
<lastname>Jain</lastname>
</customer>
<item>
<name>Milk</name>
<qty>4</qty>
<price>100.00</price>
</item>
</order>
We can also calculate the price like that,
var total=order.item.qty * order.item.price
Can we display the customers full name like that,
document.write(order.customer.lastname)
document.write(",")
document.write(order.customer.firstname)
Can add new items like that,
order.item+=
<item>
<name>Bread</name>
<qty>5</qty>
<price>70.00</price>
</item>
We can display the order id like that,
document.write(order.@id)
We can calculate the total price, when the order has many items like that,
var price=0
for each (i in order.item)
{
price+= i.qty*i.price
}
Example:
I have written an XML document.
<order>
<date>2009-26-01</date>
<customer>
<firstname>Porus</firstname>
<lastname>Jain</lastname>
</customer>
<item>
<name>Milk</name>
<qty>4</qty>
<price>100.00</price>
</item>
</order>
We can stroe this XML document as an string in variable order.
var order = new XML(txt)
'or'
Assign the XML text to the XML object variable directly.
var order = new XML()
order=<order id="010">
<date>2009-26-01</date>
<customer>
<firstname>Porus</firstname>
<lastname>Jain</lastname>
</customer>
<item>
<name>Milk</name>
<qty>4</qty>
<price>100.00</price>
</item>
</order>
We can also calculate the price like that,
var total=order.item.qty * order.item.price
Can we display the customers full name like that,
document.write(order.customer.lastname)
document.write(",")
document.write(order.customer.firstname)
Can add new items like that,
order.item+=
<item>
<name>Bread</name>
<qty>5</qty>
<price>70.00</price>
</item>
We can display the order id like that,
document.write(order.@id)
We can calculate the total price, when the order has many items like that,
var price=0
for each (i in order.item)
{
price+= i.qty*i.price
}
2 :: Tell me about browser compatibility with E4X?
E4X support limited browsers.No,mainstream browser has supported by E4X.
Mozilla engine(1.8)(beta version) is limited support to E4X.
We can say that Firebox 1.1 is an first version that support E4X.E4X is also expected to the future version of Internet Explorer.
Firefox 1.1: Firefox1.1 can support best for E4X as compare to other browsers.
Mozilla engine(1.8)(beta version) is limited support to E4X.
We can say that Firebox 1.1 is an first version that support E4X.E4X is also expected to the future version of Internet Explorer.
Firefox 1.1: Firefox1.1 can support best for E4X as compare to other browsers.
3 :: Using E4X how can we make XML easier to use?
E4X makes easier to use JavaScript to pasre and manipulate XML.This is also use to enable XML library or component to act with XML.On different browsers libraries and components perform with different syntax and work differently. I have given you example where I show how to load an existence XML document("message.xml")into XML parser and to show note from message.Example: Without use of E4X.var xmlDoc//This code is made only for Internet Explorer.if (window.ActiveXObject){xmlDoc = new ActiveXObject("Microsoft.XMLDOM")xmlDoc.async=false;xmlDoc.load("message.xml")displaymessage()}// This code is made for Mozilla, Firefox etc.else (document.implementation
4 :: Using E4X how can we define XML document as a JavaScript object?
I have given you example to show XML document as JavaScript object.Example:
I have you simple XML document.
<message>
<date>2009-26-01</date>
<to>Abhi</to>
<from>Sud</from>
<heading>Don't forget</heading>
<body>Happy Birthday!</body>
</message> We can store this XML document in a string calles as message into an XML object variable vusing JavaScript.var v = new XML(message) 'or' Assign the XML text to the XML object variable directly.var v = new XML()v=<message>
<date>2009-26-01</date>
<to>Abhi</to>
<from>Sud</from>
<heading>Don't forget</heading>
<body>Happy Birthday!</body>
</message>
We can use JavaScript like that,document.write(v.from)
Output:Sud
I have you simple XML document.
<message>
<date>2009-26-01</date>
<to>Abhi</to>
<from>Sud</from>
<heading>Don't forget</heading>
<body>Happy Birthday!</body>
</message> We can store this XML document in a string calles as message into an XML object variable vusing JavaScript.var v = new XML(message) 'or' Assign the XML text to the XML object variable directly.var v = new XML()v=<message>
<date>2009-26-01</date>
<to>Abhi</to>
<from>Sud</from>
<heading>Don't forget</heading>
<body>Happy Birthday!</body>
</message>
We can use JavaScript like that,document.write(v.from)
Output:Sud
5 :: Tell me how can we use E4X in Mozilla and Mozilla Based browsers?
To make use E4X with Mozilla and Mozilla based browsers (like: Netscape) we used Spidermonkey JavaScript engine. It has been extended to implement E4X but presently we can only use it in nightly trunk builds. The present releases Mozilla 1.7 suite, Firefox 1.0, Netscape 7.2 does not supported E4X.
6 :: What you understand about ECMA?
ECMA(The European Computer Manufacturers Association)international was founded in 1961.
ECMA is an organization made to standardization of information and Communication Technology(ICT) and Consumer Electronics(CE).
We use ECMA standard with
1.JavaScript
2.C# Language
3.International Character Sets
4.Optical Disks
5.Magnetic Tapes
6.Data Compression
7.Data Communication etc.
ECMA-262(JavaScript1.3)was standarize in Dec1999.
ECMA-357 (E4X) was standardized in June2004.
We use E4X to make JavaScript supported with XML.
ECMA is an organization made to standardization of information and Communication Technology(ICT) and Consumer Electronics(CE).
We use ECMA standard with
1.JavaScript
2.C# Language
3.International Character Sets
4.Optical Disks
5.Magnetic Tapes
6.Data Compression
7.Data Communication etc.
ECMA-262(JavaScript1.3)was standarize in Dec1999.
ECMA-357 (E4X) was standardized in June2004.
We use E4X to make JavaScript supported with XML.
7 :: How we say JavaScript as same as ECMAScript?
Because of some reasons we can say that JavaScript is same as ECMAScript.
1.ECMAScript is called as an official name for JavaScript.
2.ECMAScript is exactly same as JavaScript.
3.JavaScript is standardize by ECMA (The European Computer Manufacturers Association) organization.
1.ECMAScript is called as an official name for JavaScript.
2.ECMAScript is exactly same as JavaScript.
3.JavaScript is standardize by ECMA (The European Computer Manufacturers Association) organization.
8 :: How you define E4X?
E4X stands for ECMAScript(European Computer Manufactures Association) for XML(eXtensible Markup Language).We can called as E4X is an programing language extensionn used to adds the ECMAScript(like: ActionScript,DMDScript,E4X, JavaScript,JScript) to XML.
1. Real life meaning of E4X is "JavaScript for XML".
2. E4X is an official JavaScript standard used to add direct support for XML.
3. Using E4X we can easily make scripting for XML with JavaScript.
4. Using E4X we can declare an XML object variable as same as declare Date and Array variable.
Example:
var p = new XML()
var q = new Date()
var r = new Array()
1. Real life meaning of E4X is "JavaScript for XML".
2. E4X is an official JavaScript standard used to add direct support for XML.
3. Using E4X we can easily make scripting for XML with JavaScript.
4. Using E4X we can declare an XML object variable as same as declare Date and Array variable.
Example:
var p = new XML()
var q = new Date()
var r = new Array()