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
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