title: XPATH Expression fails in JQuery
body: <p>I ran into a problem while trying to parse an XML string returned from an Ajax Call. The structure of the XML is as follows:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;endPointDefs&gt;
   &lt;endPointDef&gt;
    &lt;useCaseId&gt;USER_LOGIN&lt;/useCaseId&gt;
    &lt;endPointUrl&gt;/core.authenticate.do&lt;/endPointUrl&gt;
    &lt;endPointUrlParams&gt;
     &lt;endPointUrlParam name="MsgFormat"&gt;
      &lt;urlParamType&gt;SYSTEM_DEFINED&lt;/urlParamType&gt;
      &lt;urlParamValueSystemDefined&gt;USER_LOGIN&lt;/urlParamValueSystemDefined&gt;
     &lt;/endPointUrlParam&gt;
     &lt;endPointUrlParam name="userId"&gt;
      &lt;urlParamType&gt;USER_PROVIDED&lt;/urlParamType&gt;
     &lt;/endPointUrlParam&gt;
     &lt;endPointUrlParam name="password"&gt;
      &lt;urlParamType&gt;USER_PROVIDED&lt;/urlParamType&gt;
     &lt;/endPointUrlParam&gt;
     &lt;endPointUrlParam name="language"&gt;
      &lt;urlParamType&gt;USER_PROVIDED&lt;/urlParamType&gt;
     &lt;/endPointUrlParam&gt;
    &lt;/endPointUrlParams&gt;
   &lt;/endPointDef&gt;
  &lt;/endPointDefs&gt;
  </code></pre>
  
  <p>However, I need the value for the  tag for the useCaseId USER_LOGIN. A typical XPATH expression for this should like this:</p>
  
  <pre><code>/endPointDefs/endPointDef[useCaseId='USER_LOGIN']/endPointUrl
  </code></pre>
  
  <p>I stored the response from the ajax call in a javascript variable as follows:</p>
  
  <pre><code>var endPointDefs=null;
  </code></pre>
  
  <p>This variable is populated from an Ajax Call as follows:</p>
  
  <pre><code>    $.ajax(
     {
      type:"POST",
      url: "&lt;%=request.getContextPath()%&gt;/data/EndPointDefs.xml",
      dataType:"XML",
      success:function(data){
            //alert("End Points Loaded: " + data);
            endPointDefs=data;
          },
        error: function() {
           alert('an error occurred! which trying to fetch the end point definitions');
            }  
     }
      );
  </code></pre>
  
  <p>I tried to execute the XPATH query using JQuery as follows:</p>
  
  <pre><code>    $("endPointDefs/endPointDef[useCaseId='USER_LOGIN']/endPointUrl",endPointDefs).each(function(){
     $('#txtUseCase').val('USER_LOGIN');
     $('#txtEntryPointURL').val($(this).text());
  
    })
  </code></pre>
  
  <p>This is a modified version of what was show here:
  <a href="http://www.compoc.com/tuts/" rel="nofollow">http://www.compoc.com/tuts/</a></p>
  
  <p>Though, an alternative approach would be to iterate over all the endPointDef elements and inspect the value of the useCaseId and if it matches my string [USER_LOGIN], then, set the text in the text box. But, a more elegant approach would be to use an XPATH expression indicated above, which would give me the desired results in one shot.</p>
  
  <p>I tried many combinations and nothing seems to work. Does JQuery support this kind of XPath queries? If so, can somebody please tell me where am I going wrong?</p>