How to edit/update a Translation Memory Unit Element via Api

I am attempting to edit a large number of Tm units.

Using the Api, this is fairly simple, as long as the Tm unit has plain text.

The problem I am facing is when the Tm unit contains tags.

If I use ToString() and Replace(), when updating the TranslationUnit, the tags are converted to "plain text".

Alternatively, I am able to loop through each item.MemoryTranslationUnit.SourceSegment.Elements.ToList(), and then use ToString() and Replace() again...this time isolating the element where the find/replace needs to take place, and not touching the other Elements.

1) Is there a way to replace text within a item.MemoryTranslationUnit.SourceSegment/TargetSegment whilst maintaining the original and untouched tag elements?
OR
2) How can I update a TranslationMemoryUnit.Element and then invoke the tm.LanguageDirection.UpdateTranslationUnit(item.MemoryTranslationUnit); method?

Thanks in advance

Parents Reply Children