When a paragraph has XML element without closing then InDesign is not allowing to create hyperlink.
For example, in the below case, the hyperlink would be created for “Content 2” but not for “Content 1” and “Content 3” as InDesign expects the opening and closing element on the same paragraph.
What version are you using ? Setting hyperlink in such a scenario works for me either manually or via script.
Any other alternative way to add hyperlink exclude xml tag.