Sample Header Ad - 728x90

'xmlstarlet edit' using a variable as XPath

3 votes
1 answer
428 views
When you follow the doc: xmlstarlet edit --help you can read that --var can be used to declare a XPath expression as a variable. Generating moc file: cat /tmp/file.xml x y EOF This one works, without variables: xmlstarlet edit \ --var xp '//elt/following::comment()' \ -a '//elt/following::comment()' -t elem -n p -v 'some new text' \ -a '//elt/following::comment()' -t elem -n p -v 'some other text' \ /tmp/file.xml This one doesn't edit with variables: xmlstarlet edit \ --var xp '//elt/following::comment()' \ -a xp -t elem -n p -v 'some new text' \ -a xp -t elem -n p -v 'some other text' \ /tmp/file.xml What does I miss to use variable?
Asked by Mévatlavé Kraspek (541 rep)
Feb 28, 2023, 08:33 AM
Last activity: Feb 28, 2023, 09:00 AM