If the file were correct xml, you could use an xml parsing tool.
Otherwise, if there were no other (nested) div section inside that section, you could have done:
pcregrep -Mo '(?s)<div[^>]*id="id1".*?</div>' the-file.html
Here, you could try something like:
awk -vRS='<' '
inside || /^div[^>]*id="id1"/ {
inside = 1
if (/^div/)
n++
else if (/^\/div>/ && !--n) {
$0="/div>\n"
inside=0
}
printf "<%s", $0
}' the-file.html