I am trying to add SAML Metadata for a service in the customer portal, but getting errors about invalid data. What is wrong?

If the error says ‘This element is not expected’ it is most likely because there is an XML element in the wrong place. Order is significant in the SAML metadata XML.

Ref: See section 2.3.1 in https://docs.oasis-open.org/security/saml/v2.0/saml-metadata-2.0-os.pdf