title: How to retrieve parent node with child node that matching certain criteria using xquery?
body: <p>I'm trying to get partial data from my xml file,<br>
  The source file is like this:</p>
  
  <pre><code>&lt;Odds&gt;
    &lt;Match ID="101" Time="A"&gt;
      &lt;Event type="Home"&gt;
        &lt;Score="1"/&gt;
      &lt;/Event&gt;
      &lt;Event type="Away"&gt;
        &lt;Score="2"/&gt;
      &lt;/Event&gt;
    &lt;/Match&gt;
    &lt;Match ID="102" Time="B"&gt;
      &lt;Event type="Home"&gt;
        &lt;Score="1"/&gt;
      &lt;/Event&gt;
      &lt;Event type="Away"&gt;
        &lt;Score="2"/&gt;
      &lt;/Event&gt;
    &lt;/Match&gt;
  &lt;/Odds&gt;
  </code></pre>
  
  <p>I want to get the Odds, Match, Event, Score tags where Event type match "Home" only.<br>
  That is, the result is as below:</p>
  
  <pre><code>&lt;Odds&gt;
    &lt;Match ID="101" Time="A"&gt;
      &lt;Event type="Home"&gt;
        &lt;Score="1"/&gt;
      &lt;/Event&gt;
    &lt;/Match&gt;
    &lt;Match ID="102" Time="B"&gt;
      &lt;Event type="Home"&gt;
        &lt;Score="1"/&gt;
      &lt;/Event&gt;
    &lt;/Match&gt;
  &lt;/Odds&gt;
  </code></pre>
  
  <p>I'm fresh to XML, have read some books.<br>
  Tried to add criteria in WHERE of xquery and RETURN the parent node.<br>
  But the result always returns the Match with full child nodes.<br>
  That is, there is no difference between the result and the original one.<br>
  Is there any good way to do to get rid of those events that the type is not Home?<br>
  Thanks for the help!  </p>