JavaScript and XML

  • From: LU OGBE <oluogbe@xxxxxxxxxxxxxx>
  • To: "Blind Programming" <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 9 Jun 2010 12:14:23 +0100

Hello,

Apologies for cross posting. Please does anyone know how I can use JavaScript 
to populate the array in the code below with contents from an XML file instead 
of just using the index numbers specified in the code? I have pasted the whole 
code so you understand what I'm trying to do. Thanks in advance.

Regards,
LU

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="http://www.w3.org/StyleSheets/TR/base";?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml";
      xmlns:aaa="http://www.w3.org/2005/07/aaa";>
<head>
<title> ARIA Live Region Polite Example </title>
<script type="text/javascript">
window.onload = politeExample;
var minimumTime = 1000;
var index=0;
var lrID = "myLiveRegion1";
var numbersArray = new Array("0","1","2","3","4","5","6","7","8","9");

function updateLiveRegion(liveRegionID, textString){
 textNode = document.createTextNode(textString);
        targetNode = document.getElementById(liveRegionID);
        while (targetNode.firstChild) {
           targetNode.removeChild(targetNode.firstChild);
           }
 targetNode.appendChild(textNode);
        }

function politeExample(){
   updateLiveRegion(lrID, numbersArray[index++]);
   if (index > 9){
      index=0;
      }
   window.setTimeout(politeExample, minimumTime);
   }

function setMinimumTime(){
   minimumTimeStr = 
document.getElementById("throttle").options[document.getElementById("throttle").selectedIndex].text;
   minimumTime = minimumTimeStr * 1000;
   }
</script>
</head>
<body>
<div>
<label for="throttle">Minimum number of seconds before a change</label>
<select id="throttle" onblur="setMinimumTime();" onchange="setMinimumTime();">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>
<hr/>
</div>
<h1>
Live Region - live="polite"
</h1>
<p>
<span id="myLiveRegion1" aria-live="polite">

</span>
</p>
</body>
</html>

Other related posts:

  • » JavaScript and XML - LU OGBE