Added option to flatten the xml.