Delete multi-line text from a file using sed

sed '/--#else--/,/--#endif--/{//!d}' test.xml

this will delete the lines between else and endif

if you want to delete else and endif as well use this:

sed '/--#else--/,/--#endif--/d' test.xml

in the case you mentioned in the comments try this:

sed -n '/--#else--/,/--#endif--/p' test.xml

-n is dont print by default and /p does the print while /!d does the delete