simple command to strip header and footer from a file
Using sed
:
sed -n '/<Document>/,/<\/Document>/ p' yourfile.xml
Explanation:
-n
makessed
silent, meaning it does not output the whole file contents,/pattern/
searches for lines including specified pattern,a
,
b
(the comma) tellssed
to perform an action on the lines froma
tob
(wherea
andb
get defined by matching the above patterns),p
stands for print and is the action performed on the lines that matched the above.
Edit: If you'd like to additionally strip the whitespace before <Document>
, it can be done this way:
sed -ne '/ <Document>/s/^ *//' -e '/<Document>/,/<\/Document>/ p' yourfile.xml