Main Page

XML in JavaScript

XML in JavaScript
With the rising popularity of XML, JavaScript developers were clamoring for a way to make use
of it in client-side Web development. When the fourth-generation browsers were released, many
developers began writing their own objects for the manipulation of XML using JavaScript. Hearing
the call, some browser developers boldly pushed toward adding support for XML and XML-
related language on the client side.
XML DOM Support in Browsers
Even though XML and the DOM have become an important part of Web development, there are
still only two browsers that support client-side XML manipulation. Not surprisingly, they are the
two most popular browsers in the world: Internet Explorer and Mozilla.
XML DOM support in IE
When looking to add XML support to Internet Explorer, Microsoft looked outside of JavaScript to
their ActiveX-based library called MSXML. MSXML was developed to provide developers with
the first DOM implementation for Windows. As an ActiveX control, MSXML could be used in con-
junction with Visual Basic, C++, and other Windows-based development environments. It made
sense to use what the company was already offering as the basis for client-side XML support.
To create an ActiveX object using JavaScript, Microsoft introduced a class called
The constructor for
takes one argument, which is the string identifying the
ActiveX object to instantiate. For example, the first version of the XML DOM object was called
. To create a new instance of this object, you would do this:
var oXmlDom = new ActiveXObject(“Microsoft.XmlDom”);
18_579088 ch15.qxd 3/28/05 11:42 AM Page 445

JavaScript EditorFree JavaScript Editor     Ajax Editor