1.

Using E4x How Can We Define Xml Document As A Javascript Object?

Answer»

I have given you example to show XML document as JavaScript object.Example:I have you SIMPLE XML document.

<MESSAGE&GT;
<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

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



Discussion

No Comment Found