E4X学习笔记

e4x可以使你在html中把XML当作一种简单类型来使用,通过var x = new XML(),来生成一个xml对象,对于xml文档的加载,可以把它看成一个xml对象,这样,就不需要通过dom来操作xml,使得xml文档的操作变得方便。例如:

<mce:script type="text/javascript;e4x=1"><!-- var note = <note>   <date>2008-08-08</date>   <to>George</to>   <from>John</from>   <heading>Reminder</heading>   <body>Don't forget the meeting this weekend!</body> </note>;//把xml文档存储在note变量 var x = new XML(note); document.write(x.from); // --></mce:script>

执行结果:John,

可惜的得,这么方便的东西, 目前支持的浏览器只有firefox。

你可能感兴趣的:(E4X学习笔记)