Load Xml Document Method
XML Menu Suite
Build powerful, client-side DHTML menus using XML for data and CSS for style. No JavaScript data! No having to place list elements on every single page of your website! No plug-ins!

Method: CJL_loadXmlDocument()

Summary:

Cross-platform JavaScript method for loading external XML files.

Submitted: 05/01/2003

Created by: CodeHouse.com

Browser Compatibility for this method

  • Internet Explorer for Windows 5.0+
  • Netscape 6.1+
  • Mozilla 1.0+

Demo

The demo loads an external XML file and displays data obtained from it.

Source Code

The source code for this method is contained in the text area below. You can copy and paste it into your own source code.

Before using the source code, make sure that you read and agree to the terms of the License Agreement, which will open in a separate window.

Method:

CJL_loadXmlDocument()

Description:

Loads an external XML document.

Example Usage:

The first parameter passed to CJL_loadXmlDocument() in the sample code below, specifies to load the XML file, demo.xml. The second parameter, myCallBack, specifies that the function myCallBack() will get called when demo.xml is loaded.

In the definition of the function myCallBack(), it is passed the parameter xdoc, which is the document associated with demo.xml. The tagname of the Document Element associated with xdoc is passed to the alert() method, which displays it in an alert box.

function myCallBack(xdoc)
{
   alert(xdoc.documentElement.tagName);
}

CJL_loadXmlDocument("demo.xml", myCallBack);

Comments:

This method can be called on non-supporting browsers without side-effects.

Parameters

xmlFile:
The external XML file to load.

cbFun:

Reference to a callback function, which gets called by CJL_loadXmlDocument() when the XML file is loaded.

The callback function has the following signature:

function callBack(xdoc)

The xdoc parameter to the callback function specifies the Document Element associated with the XML file, specified by xmlFile.

Return Value

Returns true if this method is being called on a supporting browser or false if it is not

Support

If you have any questions, find any bugs, or have suggestions, feel free to contact us.