I have an xml like below
<PO>
<ITEM>
<ID>1000</ID>
<PRICE>10</PRICE>
</ITEM>
<ITEM>
<ID>1000</ID>
<PRICE>10</PRICE>
</ITEM>
<ITEM>
<ID>1001</ID>
<PRICE>10</PRICE>
</ITEM>
<ITEM>
<ID>1001</ID>
<PRICE>10</PRICE>
</ITEM>
</PO>

I want an xpath that will get only ID = 1000 and the output should be like below
<PO>
<ITEM>
<ID>1000</ID>
<PRICE>10</PRICE>
</ITEM>
<ITEM>
<ID>1000</ID>
<PRICE>10</PRICE>
</ITEM>
</PO>

I tried /PO/ITEM[ID="1000"] but it gives the following but I need even the root "PO" also...

<ITEM>
<ID>1000</ID>
<PRICE>10</PRICE>
</ITEM>
<ITEM>
<ID>1000</ID>
<PRICE>10</PRICE>
</ITEM>

Thanks for the help

As far as I know you cannot use an XPath expression to do what you want to do.

Here is how I get the result you are looking for

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="xml" indent="yes" />

  <xsl:template match="/" >
    <xsl:element name="PO">
    <xsl:copy-of select="//ITEM[ID='1000']" />
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>