This article mainly introduces the use of JavaScript to get the maximum value of XML nodes. Need friends can come to the reference, I hope to help you.
Suppose the current time is now 7000 milliseconds. When the time is 3000--6000 is to go 3000 value, when 6000--9000 to take 6000 of the value, that is, take the XML is less than the current time maximum XML file, code as follows: <?xml version= "1.0" encoding= "Utf-8"?> <catalog> <cd> <ID>2</ID> <title> 1th talk </title> <mediaurl >123</mediaUrl> <htmlUrl>1.html</htmlUrl> <orderNo>2</orderNo> <studytimes >00:00:30</StudyTimes> <secondss times= "30000" >1.html</Secondss> </cd> <cd> <id >3</ID> <title> 2nd lecture </title> <mediaUrl>123</mediaUrl> <htmlurl>2.html</ htmlurl> <orderNo>2</orderNo> <StudyTimes>00:01:00</StudyTimes> <secondss times= " 60000 ">2.html</Secondss> </cd> <cd> <ID>4</ID> <title> 3rd Talk </title> < Mediaurl>123</mediaurl> <htmlUrl>3.html</htmlUrl> <orderNo>2</orderNo> < studytimes>00:01:30</studytimes> <secondss times= "90000" >3.html</seconDss> </cd> </catalog> javascript: MediaPlayer.Controls.CurrentPosition * 1000 for the current time The code is as follows: function times () {//define array array var array =new array ();//define XMLDOM protocol var xmldom =new ActiveXObject ("Microsoft.XMLDOM" ); Xmldom.async =false; Load XML file Xmldom.load (Id.value + "_imsmanifest.xml"); Jump try {//Find all Secondss x = Xmldom.getelementsbytagname ("Secondss");//traverse for (I =0; i < x.length; i++) {//Fetch times Property var s = X[i].getattribute ("Times"); If the property value is less than MediaPlayer.Controls.CurrentPosition * 1000, it is added to the array if (S <= MediaPlayer.Controls.CurrentPosition *1000) { Array.push (s); }//Sort array at this time array[array.length-1] is less than the maximum value of MediaPlayer.Controls.CurrentPosition * 1000 array.sort (); }