TESTLINK エキスポートXMLにHTMLタグを含めない。

TESTLINKには他システムとのIF用にテストスィーツをXML形式でエキスポート,インポートできる機能がある。便利な機能ではあるが、TESTLINK上でテストケースはHTMLフォーマットで記述することができる関係から、エキスポートしたXML上に目には見えないHTMLタグがついてきてしまう。(ワードで下書きしたものをコピペした時などはすばらしくCSSな文字列になっている。)私の場合は、エキスポートXMLデータを西山さんのEXCELマクロで取り込んで、報告資料に流用しているためこのHTMLタグを手動で削除しなければならない。面倒くさいので、TESTLINKのソースを変更した。
(注) TESTLINK1.7.4にEXCELマクロのバッチ-(XMLファイル変換マクロ TestLinkCnvMacro ver. 4.4a)が当たっていることが前提。

lib/functions/testcase.class.phpのexportTestCaseDataToXMLを以下のように変える。
以下はテストケース名、ステップ、サマリ、期待結果からHTMLタグをとった例。
他の項目から除去したい場合は、下をまねして追加する。
strip_tagsはHTMLタグを取り除くPHP関数であるが完全には取りきれないので、str_replace関数で補完している。

function exportTestCaseDataToXML($tcase_id,$tcversion_id,$bNoXMLHeader = false,$optExport = array(),
                                $testplanid=0, $buildid=0, $kindsub=null )   // by hnishi for TestLinkCnvMacro(2.0)
{
        $tc_data = $this->get_by_id($tcase_id,$tcversion_id);

        //new dBug($tc_data);
        $tc_data[0]['testcaseid'] = $tcase_id;  // by hnishi for TestLinkCnvMacro(1.51)
// by hnishi for TestLinkCnvMacro(2.0)  ---------------------->
        //printf( "testplanid=%d buildid=%d <br>", $testplanid, $buildid );
        $author_id = $tc_data[0]['author_id'];
        $tc_data[0]['author']           = $kindsub->getUserNameById($author_id);

        $result = $kindsub->getTCResult($testplanid, $buildid, $tcase_id, 0);
        $tc_data[0]['tester']           = $result[0]['tester'];
        $tc_data[0]['expecteddate']     = $result[0]['ts'];
        $tc_data[0]['results']          = $result[0]['result'];
        $tc_data[0]['executionnotes']   = $result[0]['notes'];
        $tc_data[0]['bugid']            = $result[0]['bugid'];
        $tc_data[0]['executionid']      = $result[0]['id'];
        $tc_data[0]['tcversionid']      = $result[0]['tcversion_id'];
// by hnishi for TestLinkCnvMacro(2.0)  <----------------------
// by hnishi for TestLinkCnvMacro(4.1)  -------------------------->

//2009-07-15 R.Funaki start ここから変更開始
        $tc_data[0]['name'] = html_entity_decode(strip_tags($tc_data[0]['name']), ENT_QUOTES, 'UTF-8');
        $tc_data[0]['name'] = str_replace('&nbsp;', ' ', $tc_data[0]['name']);
        $tc_data[0]['name'] = str_replace('&rdquo;', '\"',  $tc_data[0]['name']);
        $tc_data[0]['name'] = str_replace('&quot;', '\"', $tc_data[0]['name']);

        $tc_data[0]['steps'] = html_entity_decode(strip_tags($tc_data[0]['steps']), ENT_QUOTES, 'UTF-8');
        $tc_data[0]['steps'] = str_replace('&nbsp;', ' ', $tc_data[0]['steps']);
        $tc_data[0]['steps'] = str_replace('&rdquo;', '\"',  $tc_data[0]['steps']);
        $tc_data[0]['steps'] = str_replace('&quot;', '\"', $tc_data[0]['steps']);

        $tc_data[0]['summary'] = html_entity_decode(strip_tags($tc_data[0]['summary']), ENT_QUOTES, 'UTF-8');
        $tc_data[0]['summary'] = str_replace('&nbsp;', ' ',  $tc_data[0]['summary']);
        $tc_data[0]['summary'] = str_replace('&rdquo;', '\"',  $tc_data[0]['summary']);
        $tc_data[0]['summary'] = str_replace('&quot;', '\"', $tc_data[0]['summary']);

        $tc_data[0]['expected_results'] = html_entity_decode(strip_tags($tc_data[0]['expected_results']), ENT_QUOTES, 'UTF-8');
        $tc_data[0]['expected_results'] = str_replace('&nbsp;' ,' ', $tc_data[0]['expected_results']);
        $tc_data[0]['expected_results'] = str_replace('&rdquo;', '\"',  $tc_data[0]['expected_results']);
        $tc_data[0]['expected_results'] = str_replace('&quot;', '\"', $tc_data[0]['expected_results']);
//2009-07-15 R.Funaki end ここで変更終了

これでXMLの指定箇所には、HTMLタグが入らなくなる。