Jquery查询XML文档where子句
我有一个XML文档,我想搜索一个特定的日期并获取该日期的信息。我的XML如下所示:Jquery查询XML文档where子句,jquery,xml,where-clause,Jquery,Xml,Where Clause,我有一个XML文档,我想搜索一个特定的日期并获取该日期的信息。我的XML如下所示: <month id="01"> <day id="1"> <eitem type="dayinfo"> <caption> <text lang="cy">f. 3 r.</text>
<month id="01">
<day id="1">
<eitem type="dayinfo">
<caption>
<text lang="cy">f. 3 r.</text>
<text lang="en">f. 3 r.</text>
</caption>
<ref href="link" id="3"/>
<thumb href="link" id="3"/>
</eitem>
</day>
<day id="7">
<eitem type="dayinfo">
<caption>
<text lang="cy">f. 5 v.</text>
<text lang="en">f. 5 v.</text>
</caption>
<ref href="link" id="4"/>
<thumb href="link" id="4"/>
</eitem>
</day>
<day id="28">
<eitem type="dayinfo2">
<caption id="1">
<text lang="cy">test</text>
<text lang="en">test2</text>
</caption>
<ref href="link" id="1"/>
<thumb href="link" id="1"/>
</eitem>
</day>
<day id="28">
<eitem type="dayinfo">
<caption>
<text lang="cy">f. 14 v.</text>
<text lang="en">f. 14 v.</text>
</caption>
<ref href="link" id="20"/>
<thumb href="link" id="20"/>
</eitem>
</day>
</month>
$(xml).find('month[id=01]').each(function()
{
$(xml).find("day").each(function()
{
var day = $(this).attr('id');
alert(day);
});
});
在上面的XML示例中,我只显示了一个月,但是还有更多。
在我的JQuery中,我尝试执行“Where month=1”并获取该月的所有天数信息,但是JQuery会为每个月返回天数。如何在XML文档上使用JQuery/JavaScript创建where子句?谢谢
$(xml).find('month[id=01]').each(function()
{
$(this).find("day").each(function()
// ^^^^
{
var day = $(this).attr('id');
alert(day);
});
});