This article mainly aims to read data from the XML file, and then return the data to the page using a third-party plug-in for plotting, and provides a detailed solution, if you are interested, you may find it helpful.
Let's talk about this application scenario first.:
Read data from the XML file, and then return the data to the page using a third-party plug-in for plotting.
The data read in XML is of course a string type, and if you want to use the time mode of the X axis of the drawing plug-in (in this way, you can customize the data such as the X axis range and the format of the X axis data more reasonably ). The data must be converted to a standard time object. At this time, the built-in Date type in js comes in handy:
The Code is as follows:
Var date = new Date ();
// The input field with the id of time contains the time information extracted in xml.
Date. setHours ($ ("# time"). val (). substring (0, 2) + 8 );
Date. setMinutes ($ ("# time"). val (). substring (2, 4 ));
Date. setSeconds ($ ("# time"). val (). substring (4, 6 ));
The time type in XML is in the format of hour, minute, and second (for example, 083100 ), after obtaining the data, you can instantiate the Date object using time-setting functions such as setHours, setMinutes, and setSeconds.