Sunday, 19 August 2007

AJax example for reading xml file

Requested file :

* test.html - main html test page
* test.xml - xml file as a source for reading
* jslb_ajax.js - ajax component javascript file

******** test.xml *******
<?xml version="1.0" encoding="UTF-8"?>
<testdata> this is the text source part </testdata>

******* jslb_ajax.js ***********
download ajax component

***** test.html ******
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="Javascript" src="jslb_ajax.js" charset="utf-8"></script>
<script type="text/javascript">
function clickButton() {
sendRequest(load_xmlFile, '', 'GET', 'test.xml', true, true);

function load_xmlFile(oj) {
var xmlDoc = oj.responseXML;
var nodes = xmlDoc.getElementsByTagName("testdata");
<title>Test page</title>
<input type="button" value="read test.xml and display it" onclick="clickButton()">

No comments: