[IMP] improved code. Added new method and pass attribute in SubElement to set attribut.