Get merge sections

How to retrieve list of merge sections that exist in a document? I have merge sections defined like this in my document,

<S:PersonalInfo><first_name><E:PersonalInfo>

where PersonalInfo is a section and it contains merge field first_name.
Any help would be appreciated!

@wajihaFarooqui Could you please attach your template here for testing? We will check it and provide you more information.

I’ve created a sample document. May be i didn’t use the right word, i meant merge regions. I am writing a utility that should print list of merge regions used in a document.
sample.docx (18.6 KB)

@wajihaFarooqui Thank you for additional information. In case of using mail merge regions, you can use MailMerge.getRegionsHierarchy method to get information about regions in your template. But in your sample document, you are using custom field names for regions. In this case you can get field names using MailMerge.getFieldNames

Document doc = new Document("C:\\Temp\\sample.docx");

for (String name : doc.getMailMerge().getFieldNames())
    System.out.println(name);

Where merge field name that starts with “S:” is considered as start of region and “E:” as End of region.