Jquery query XML document where clause

Posted by user578406 on Stack Overflow See other posts from Stack Overflow or by user578406
Published on 2011-01-17T10:49:33Z Indexed on 2011/01/17 10:53 UTC
Read the original article Hit count: 256

Filed under:
|
|

I have an XML document that I want to search a specific date and get information for just that date. My XML looks like this:

    <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>

My Jquery looks like this:

            $(xml).find('month[id=01]').each(function()
            {
                $(xml).find("day").each(function()
                {
                    var day = $(this).attr('id');
                    alert(day);
                });
            });

In the XML example above I only shown one month, however there are many more. In my JQuery I've tried to do 'Where month = 1' and get all the days info for that month, however that JQuery brings back days for every month. How do I do a where clause with JQuery/JavaScript on a XML document? thanks.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about Xml