E4X



Totel:8 Click: 1 2
E4X Interview Questions And Answers

Page 1

 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.

 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.priceCan
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=0for each (i in order.item)
 { 
   price+= i.qty*i.price
 }

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.

 E4X makes easier to use JavaScript to parse 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 existance 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

 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>
Happy Birthday!</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>
Happy Birthday!</message>

We can use JavaScript like that,document.write(v.from)

Output:
Sud


Goto Page:

1 2
E4X Objective Questions And Answers

E4X Objective Questions And Answers

E4X Interview Questions And Answers

E4X Subjective Questions And Answers


R4R,E4X Objective fresher and experienced, E4X Subjective fresher and experienced ,E4X Interview Questions And Answers,E4X fresher and experienced,E4X Interview fresher and experienced ,E4X Questions fresher and experienced,E4X Answers fresher and experienced