I was trying to parse out text between specific tags on a mac in various html files. I was looking for the first heading in the body. Example:
Try the --html
option. Otherwise, xmllint
parses your document as XML which is a lot stricter than HTML. Also note that XPath indices are 1-based and that HTML tags are converted to lowercase when parsing. The command
xmllint --html --xpath '/html/body/h1[1]' - <<EOF
<BODY>
<H1>Dublin</H1>
EOF
prints
<h1>Dublin</h1>