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(同一文件,不同数据,递增原数据没有被覆盖情况下增加数据.)
教个要点或最好是有个代码提示的
过路好汉 帮个忙撒^^
不会,帮楼主 ......
Private Sub Command1_Click()
Dim MyString() As String
Open "a.xml" For Binary As #1 ' 打开刚创建的文件。
ReDim MyString(LOF(1) - 1)
Put #1, , MyRecord ' 读入所有字符到变量中 ......
我要在网页上上传一个XML文件,我在C#中写了一个验证XML文件格式的方法:
private bool ValidateXml(string xmlFilePath)
{
string xsdPath = Request.PhysicalApp ......
思路:要用c#生成一个播放机的播放列表的xml,例如:
<daty datys='2010-04-05' datye='2010-05-01' > //这是播放的日期段
<time times='01:12:00' timee='02:30:00'> ......
xml文件格式如下
XML code:
<?xml version="1.0" encoding="GB2312" ?>
<allproducts version="1.0">
<products>
<product name="prodId&quo ......