js 解析 xml 中的时间 - Web 开发 / JavaScript
请教各位!需求是这样的,获取xml中的时间段。
例如:我想获取2010-1-1 到 2010-2-2之间的数据。
xml文件格式
<voice id="000001" begintime="2010-1-1 1:1:1" endtime="2010-1-1 2:3:5" filename="E:/voices/v000001.wav"/>
我的JS应该怎么去获取。
因为只能用HTML文件读取xml文件,没有JDK或容器的环境。
var xmlDoc;
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load("ChinaArea.xml");
var voices = xmlDoc.DocumentElement.getElementsByTagName("voice");
for(var i=0;i<voices.length;i++){
alert(voices[i].getAttribute("begintime")+" "+voices[i].getAttribute("endtime"));
}
voices[i].getAttribute("begintime")+" "+voices[i].getAttribute("endtime");
主要是这个,其余的网上有很多例子
时间紧!我只能采用读出数据然后进行时间的比对。哎!没办法。上万条的数据查时间相当的慢
相关问答:
txt 和XML 格式相应
不借助DataSet
导入读取TXT文件
然后直接写入XML(同一文件,不同数据,递增原数据没有被覆盖情况下增加数据.)
教个要点或最好是有个代码提示的
过路好汉 帮个忙撒^^
不会,帮楼主 ......
<?xml version="1.0" encoding="utf-8" ?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical&q ......
现在有个xml文件是<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xm ......
xml文件格式如下
XML code:
<?xml version="1.0" encoding="GB2312" ?>
<allproducts version="1.0">
<products>
<product name="prodId&quo ......