3 ms·
> Regarding xmlstarlet, I don't use it much but here's some stuff from my notes: It is also handy doing at some PoC work, and then one can feed it "-C" to outp
by mdaniel 4y ago
> Regarding xmlstarlet, I don't use it much but here's some stuff from my notes:
It is also handy doing at some PoC work, and then one can feed it "-C" to output the backing xslt for use elsewhere
$ echo '<a><b>hello</b></a>' | xmlstarlet sel -t -m /a -c 'count(*)' --nl
1
$ echo '<a><b>hello</b></a>' | xmlstarlet sel -C -t -m /a -c 'count(*)' --nl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output omit-xml-declaration="yes" indent="no"/>
<xsl:template match="/">
<xsl:for-each select="/a">
<xsl:copy-of select="count(*)"/>
<xsl:value-of select="'
'"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>