Javascript gets the maximum of of implementation code for the XML node

  • 2020-03-30 00:50:03
  • OfStack

Suppose the current time is 7000 milliseconds. When the time is 3000--6000 is the value of 3000, when the time is 6000--9000 is the value of 6000, that is, the maximum value in the XML is less than the current time

The XML file,

<?xml version="1.0" encoding="utf-8"?>
<title> The first 1 speak </title>
<Secondss times="30000">1.html</Secondss>
<title> The first 2 speak </title>
<Secondss times="60000">2.html</Secondss>
<title> The first 3 speak </title>
<Secondss times="90000">3.html</Secondss>


MediaPlayer. Controls. CurrentPosition * 1000 to the current time

function times() {
//Define array array
var array =new Array();
//Define the xmldom protocol
var xmlDom =new ActiveXObject("Microsoft.XMLDOM");
xmlDom.async =false;
//Load XML file
xmlDom.load(id.value +"_imsmanifest.xml"); // jump 
try {
//Find all the Secondss
x = xmlDom.getElementsByTagName("Secondss");
// traverse 
for (i =0; i < x.length; i++) {
//Take times attribute
var s = x[i].getAttribute("times");
//If the attribute value is less than the MediaPlayer. Controls. CurrentPosition * 1000 is added to the array
if (s <= MediaPlayer.Controls.CurrentPosition *1000) {
//Sorted array the array (array. The length - 1) is less than the MediaPlayer. Controls. CurrentPosition * 1000 the maximum inside

Related articles: