JavaScript gets the maximum value of an XML node

Source: Internet
Author: User
Tags current time

  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 (); }
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.