1

現在、ある CMS から別の CMS に XML を移行しており、一部のテキストを要素に変換する必要があります。システムの仕組みにより、一部の編集者はエスケープされたテキストしか入力できません。課題は、これらのエスケープされた要素の一部を置き換えて、有効な XML 要素に変換することです。

ソースファイル:

<p>Press the &lt;button-name&gt;Select key &lt;/button-name&gt;to show more information.</p>
<p>Press the &lt;button-name&gt;Back key&lt;/button-name&gt; to save the 
values.</p>
<p>When the storage is completed, the &lt;product-name/&gt; machine
displays:</p>
<p>&lt;attention&gt;
&lt;display-text translate="no"&gt;STORAGE COMPLETED
Press BACK to exit&lt;/display-text&gt;
&lt;/attention&gt;</p>

私がしたいこと

 Replace &lt;button-name&gt; with <gui>
 Replace &lt;button-name&gt; 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>&lt;attention&gt; &lt;display-text translate="no"&gt;STORAGE COMPLETED 
 Press BACK to exit&lt;/display-text&gt;
&lt;/attention&gt;</p>

文字列ベースの検索と置換を使用しようとしましたが、出力として適切な XML 要素が必要なため、これでは実行できません。

4

1 に答える 1