How to remove text between a tag from XML or HTML with SED

Tagged sed, html, xml, xmlstarlet  Languages bash

This will remove the users tag and everything in between the users tag:

sed -i .bak '/<users type="array">/,/<\/users>/d' users.xml

A backup will be created named users.xml.bak.

If you want to select only specific tags use this:

sed -n -e '/<private-parts>/,/<\/private-parts>/p' e users.xml

For more advanced XML processing use: * XMLStarlet * xml-coreutiles * xml2/2xml * Your imagination.