XMLStarlet – a command-line utility to deal with XML documents

CAVEAT: “xmlstarlet sel --template --value-of XPATH” lists all values on a separate new line — but the last entry comes without a trailing new-line character. If you want to pipe xmlstarlet’s output into “while read e; do ...; done“, the last entry won’t get read. xmlstarlet has another option for this: “--nl” (it means: “finish each printed match with a new line”). So if you write your command line like this: “xmlstarlet sel --template --value-of XPATH --nl“, everything will be fine.
It took me a while to find out, that the last entry does not got processed, and then how to fix this.

This site uses Akismet to reduce spam. Learn how your comment data is processed.