<p>See the layout of an XML document</p>

<pre><code>
$ xmlstarlet elements planets.xml
xml
xml/sol
xml/sol/planet
xml/sol/planet/name
xml/sol/planet/albedo
xml/sol/planet
xml/sol/planet/name
xml/sol/planet/albedo
xml/sol/planet
xml/sol/planet/name
xml/sol/planet/albedo
</code>
</pre>

<p>See content of the <strong>planet</strong> node</p>

<pre><code>
$ xmlstarlet select -t --value-of '/xml/sol/planet' planets.xml

        Mercury
        0.11

        Venus
        0.7

        Terra
        0.39
</code></pre>

<p>Get the third instance of the <strong>planet</strong> node</p>

<pre><code>
$ xmlstarlet select -t --value-of '/xml/sol/planet[3]' planets.xml
Terra
0.39
</code></pre>

<p>Get only the planets with an albedo greater than 0.25</p>

<pre><code>
$ xmlstarlet select -t --value-of '/xml/sol/planet[albedo > 0.25]' planets.xml

Venus
0.7

Terra
0.39
</code></pre>

<p>Get only the planets closer to Sol than the third planet</p>

<pre><code>
$ xmlstarlet select -t --value-of '/xml/sol/planet[position() < 3]' planets.xml

Mercury
0.11

Venus
0.7
</code></pre>

<p>Learn more XPath functions at <a href="https://developer.mozilla.org/en-US/docs/Web/XPath" target="_blank">Mozilla Developer Network</a>.</p>

<p>Download xmlstarlet from <a href="https://xmlstar.sourceforge.net"
target="_blank">xmlstar.sourceforge.net</a> (<a href="https://sourceforge.net/projects/xmlstar/">https://sourceforge.net/projects/xmlstar/</a>).
</p>
