title: How to get parent element with attribute using xpath
body: <p>I have posted sample XML and expected output kindly help to get the result.</p>
  
  <p>Sample XML</p>
  
  <pre><code>&lt;root&gt;
    &lt;A id="1"&gt;
      &lt;B id="2"/&gt;
      &lt;C id="2"/&gt;
    &lt;/A&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>&lt;A id="1"/&gt;
  </code></pre>