JQuery contains exact search
<p>I'm using JQuery to parse some xml and having trouble with the line below:</p>

<pre><code>$(xml).find("ACT:contains(" + selectedAct + ")&gt;SCENE").each(function()
</code></pre>

<p>For example, if the selected act is 'ACT I', then the above line finds not only 'ACT I', but also 'ACT II', 'ACT IV', and so on, i.e. it is returning all acts that contain the variable selectedAct.</p>

<p>Any help is much appreciated. I've seen examples where 'filter' is used with an anonymous function, but I don't know how to structure it in relation to my code above.</p>

<p>Any ideas?</p>

<p>Many thanks</p>

<p>EDIT: </p>

<p>XML sample:</p>

<pre><code>&lt;ACT&gt;&lt;TITLE&gt;ACT I&lt;/TITLE&gt;

&lt;SCENE&gt;&lt;TITLE&gt;SCENE I.  Alexandria. A room in CLEOPATRA's palace.&lt;/TITLE&gt;
&lt;STAGEDIR&gt;Enter DEMETRIUS and PHILO&lt;/STAGEDIR&gt;

&lt;SPEECH&gt;
&lt;SPEAKER&gt;PHILO&lt;/SPEAKER&gt;
&lt;LINE&gt;Nay, but this dotage of our general's&lt;/LINE&gt;
</code></pre>

<p>DTD:</p>

<pre><code>&lt;!-- DTD for Shakespeare    J. Bosak    1994.03.01, 1997.01.02 --&gt;
&lt;!-- Revised for case sensitivity 1997.09.10 --&gt;
&lt;!-- Revised for XML 1.0 conformity 1998.01.27 (thanks to Eve Maler) --&gt;

&lt;!ENTITY amp "&amp;#38;#38;"&gt;
&lt;!ELEMENT PLAY     (TITLE, FM, PERSONAE, SCNDESCR, PLAYSUBT, INDUCT?,
                         PROLOGUE?, ACT+, EPILOGUE?)&gt;
&lt;!ELEMENT TITLE    (#PCDATA)&gt;
&lt;!ELEMENT FM       (P+)&gt;
&lt;!ELEMENT P        (#PCDATA)&gt;
&lt;!ELEMENT PERSONAE (TITLE, (PERSONA | PGROUP)+)&gt;
&lt;!ELEMENT PGROUP   (PERSONA+, GRPDESCR)&gt;
&lt;!ELEMENT PERSONA  (#PCDATA)&gt;
&lt;!ELEMENT GRPDESCR (#PCDATA)&gt;
&lt;!ELEMENT SCNDESCR (#PCDATA)&gt;
&lt;!ELEMENT PLAYSUBT (#PCDATA)&gt;
&lt;!ELEMENT INDUCT   (TITLE, SUBTITLE*, (SCENE+|(SPEECH|STAGEDIR|SUBHEAD)+))&gt;
&lt;!ELEMENT ACT      (TITLE, SUBTITLE*, PROLOGUE?, SCENE+, EPILOGUE?)&gt;
&lt;!ELEMENT SCENE    (TITLE, SUBTITLE*, (SPEECH | STAGEDIR | SUBHEAD)+)&gt;
&lt;!ELEMENT PROLOGUE (TITLE, SUBTITLE*, (STAGEDIR | SPEECH)+)&gt;
&lt;!ELEMENT EPILOGUE (TITLE, SUBTITLE*, (STAGEDIR | SPEECH)+)&gt;
&lt;!ELEMENT SPEECH   (SPEAKER+, (LINE | STAGEDIR | SUBHEAD)+)&gt;
&lt;!ELEMENT SPEAKER  (#PCDATA)&gt;
&lt;!ELEMENT LINE     (#PCDATA | STAGEDIR)*&gt;
&lt;!ELEMENT STAGEDIR (#PCDATA)&gt;
&lt;!ELEMENT SUBTITLE (#PCDATA)&gt;
&lt;!ELEMENT SUBHEAD  (#PCDATA)&gt;
</code></pre>
