I'm using xmllint in a bash script to perform an xpath on some data. The xpath will not always match against the data, and this is ok. From xmllint documentation:
--xpath "XPath_expression"
Run an XPath expression given as argument and print the result. In case of a nodeset result, each node in the node set is serialized in full in the output. In case of an empty node set the "XPath set is
empty" result will be shown and an error exit code will be returned.
Is there anyway to disable/hide the output XPath set is empty
when xmllint doesn't find any matches?
The message goes to the standard error device. You can redirect it to /dev/null
.
Example:
# Shows the message
xmllint --xpath '//a' <(echo "<data/>")
# Redirects the message. Message disappears
xmllint --xpath '//a' <(echo "<data/>") 2>/dev/null
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With