what is the best way to target a specific one and then drill down its child
The correct XPath expression for this is:
/resources/item[@id="index.php"]/description/text()
In plain English: Start with a node document, on a resources document element, on its child item element, but only if the id attribute value is "index.php", on its child description element and get its text value.
I use xmllint to validate XML documents, but never for path expressions. In the bash shell (at least with Mac OS) there is an even simpler tool for evaluating XPath expressions called "xpath":
$ xpath en.xml '/resources/item[@id="index.php"]/description/text()'
Then the following result is obtained:
Found 1 nodes: -- NODE -- DESCRIPTION
If you still prefer xmllint, use it as follows:
$ xmllint --xpath '/resources/item[@id="index.php"]/description/text()' en.xml > result.txt
By default, --xpath implies --noout , which prevents xmllint from being output. Redirect the output to a file.
$ cat result.txt DESCRIPTION
source share