I have to translate some details using a Google API which we're paying for. The details contain HTML, and Google charges for each character. I don't want to send the complete content, but only the English text instead, with the HTML removed. I can remove HTML tags and entities using PHP functions, but I have to place the English content back in the HTML tags after translation for proper display. It will also include CSS.
Example:
<strong>This is a test</strong><br /> <custom tag>This is a test</custom tag><br />
After translation to Spanish I need:
<strong>Translated content </strong><br /> <p>Translated content </p><br />
How can I preserve the HTML format with out sending HTML to the API?