Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Coding/Programming Interviews:Active Template Library (ATL)ActiveXApplication DeveloperArtificial intelligenceAssemblyAssociate Software EngineerAWKAWTC ProgrammingC++ ProgrammingCGI PerlCGI ProgrammingCMMICobolCritical ReasoningData Structures TreesDCOM COMDelphiDTDE4XExtensible Stylesheet Language (XSL)FortranFull-Stack DeveloperHaskellHTML DOMILUIPhone DeveloperJasper Reports DeveloperJava DeveloperLisp ProgrammingLotus NotesMicrosoft Foundation Class (MFC)Mobile DeveloperMVC DeveloperNode.jsOOPPascalPerl ProgrammingPHPPHP DeveloperProgrammingProgramming AlgorithmsProgramming ConceptsPythonRubyRuby on RailsRuby on Rails DeveloperSenior Front End DeveloperSenior Software DeveloperSignature ProgramSOASocket ProgrammingSoftware Development EngineerSoftware engineeringSr. PHP ProgrammerStack And QueueSTLSwift DeveloperTCL (Tool Command Language)Team Leader Android DeveloperUMLUnity 2D Games DeveloperUnity 3D DeveloperUnity DeveloperVBA (Visual Basic for Applications)Visual Basic (VB)Visual C++Web DevelopmentWin32APIWindows ProgramingWordPress DevelopmentWSDLXFormsXHTMLXLinkXMLXPathXQueryXSL-FOXSLT
Copyright © 2018. All Rights Reserved
E4X Interview Question:
How to use of E4X with XML?
Submitted by: AdministratorAd
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
}
Submitted by: Administrator
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
}
Submitted by: Administrator
Copyright 2007-2025 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.