現在、ある CMS から別の CMS に XML を移行しており、一部のテキストを要素に変換する必要があります。システムの仕組みにより、一部の編集者はエスケープされたテキストしか入力できません。課題は、これらのエスケープされた要素の一部を置き換えて、有効な XML 要素に変換することです。
ソースファイル:
<p>Press the <button-name>Select key </button-name>to show more information.</p>
<p>Press the <button-name>Back key</button-name> to save the
values.</p>
<p>When the storage is completed, the <product-name/> machine
displays:</p>
<p><attention>
<display-text translate="no">STORAGE COMPLETED
Press BACK to exit</display-text>
</attention></p>
私がしたいこと
Replace <button-name> with <gui>
Replace <button-name> with <kt.in name="custom-name"/>
Keeping other escaped elements.
欲しいXML
<p>Press the <gui>Select key</gui>to
show more information.</p>
<p>Press the <gui>Back key</gui>
to save the calibrations values.</p>
<p>When the storage is completed, the <kt.in name="custom-name"/> machine
displays:</p>
<p><attention> <display-text translate="no">STORAGE COMPLETED
Press BACK to exit</display-text>
</attention></p>
文字列ベースの検索と置換を使用しようとしましたが、出力として適切な XML 要素が必要なため、これでは実行できません。