Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Javascript或jQuery-查找属性日期范围正确的节点_Javascript_Jquery_Xml - Fatal编程技术网

使用Javascript或jQuery-查找属性日期范围正确的节点

使用Javascript或jQuery-查找属性日期范围正确的节点,javascript,jquery,xml,Javascript,Jquery,Xml,使用Javascript(最好是jQuery),我需要访问“节点”,其中“X”日期将在其“开始”和“结束”日期内 XML示例: <nodes> <node begin="2014-01-01" end="2014-01-31"> <info1>blah blah</info1> <info2>blah blah</info2> <info3>blah bla

使用Javascript(最好是jQuery),我需要访问“节点”,其中“X”日期将在其“开始”和“结束”日期内

XML示例:

<nodes>
    <node begin="2014-01-01" end="2014-01-31">
        <info1>blah blah</info1>
        <info2>blah blah</info2>
        <info3>blah blah</info3>
    </node>
    <node begin="2014-02-01" end="2014-02-28">
        <info1>blah blah</info1>
        <info2>blah blah</info2>
        <info3>blah blah</info3>
    </node>
    <node begin="2014-03-01" end="2014-03-31">
        <info1>blah blah</info1>
        <info2>blah blah</info2>
        <info3>blah blah</info3>
    </node>
</nodes>

废话
废话
废话
废话
废话
废话
废话
废话
废话
非常感谢您的帮助。

请使用并尝试以下代码

var startDate = new Date(2014,01,01)
  , endDate   = new Date(2014,01,31)
  , date  = new Date(2014, 01, 15)
  , range = moment().range(startDate, endDate);

您可以使用
.filter()
方法:

var nodes = $(xml),
    x = new Date("...");

var matched = nodes.children().filter(function() {
    var b = new Date( this.getAttribute('begin') ),
        e = new Date( this.getAttribute('end') );
    return b <= x && x <= e;
});
var节点=$(xml),
x=新日期(“…”);
var matched=nodes.children().filter(函数()){
var b=新日期(this.getAttribute('begin')),
e=新日期(this.getAttribute('end'));

return b是否有代码?解析XML以查找开始日期、结束日期和当前日期